Archive for category ASP.NET

WebsiteSpark Unsubscribe – is it possible?

I would say it is not. Why? Well, because they send you a broken unsubscribe links.
Of course i did that long time ago in the account options (currently cancelled) but it kept sending me various emails.
Most of them if not all, do not contain an unsubscribe link. And now they finally added the link at the footer but it does not work.
If you click it does nothing as it starts with “file:///C%7C/Users/Stephen/Desktop/Projects” etc.
This is the whole link:
Read the rest of this entry »

Change Visual Studio 2010 Development Server (Cassini) Port Number

You guys probably know that Visual Studio includes a lightweight ASP.NET development server which is an enhanced version of Cassini.

You may have noticed or heard, people want to change the port number of it so here we go;

1. Rigth click your website in Solution Explorer window and select Properties from the context menu (Alt + Enter). Read the rest of this entry »

RadControls For ASP.NET AJAX 2011 Q1

RadControl for ASP.NET AJAX
Hello Guys,

Before I continue I would like to mention that I deleted the previous version of this review which was much longer, and more eloquent but then I realized that it is not necessary at all. Simplified, the Telerik controls are a must for every serious asp.net developer.

Ok here we go:

I am fairly new to Telerik stuff and I am wondering where to start really. Nevertheless I am very pleasantly surprised by the overall look and performance.

Actually I have NOT been so pleasantly surprised for longer. I cannot resist mentioning that I love its ease of use and above all, easy of install.

Well, usually you use the standard installation (.MSI Setup) but, rather you can DL the libraries and simply add a reference to DLL’s . Voila! You are all set up to use RadControls for ASP.NET AJAX.

It can’t be simpler, right? Read the rest of this entry »

ASP.NET versus ASP Classic

ASP.NET is SuperiorIf you often revise your decision to go for .NET. then let me tell you a few things about ASP.NET.

By the way, if I have to be an ASP developer starting now I would rather work as a cleaner in a public WC indeed.

Here we go:  Read the rest of this entry »

How to Remove unused Application Pools using ServerManager Class

Public Sub RemoveUnusedApplicationPools()
        Dim manager As New ServerManager
        Dim AppPools As New List(Of String)
        ' fill the list with all pools
        For Each apppool As ApplicationPool In manager.ApplicationPools
            AppPools.Add(apppool.Name)
        Next
 
        ' if it's used remove from the total list
        For Each website As Site In manager.Sites
            For Each app As Application In website.Applications
                AppPools.Remove(app.ApplicationPoolName)
            Next
        Next
 
        ' remove the unused pools
        For Each unusedApplicationPool As String In AppPools
            Dim apppool As ApplicationPool = manager.ApplicationPools(unusedApplicationPool)
            manager.ApplicationPools.Remove(apppool)
        Next
 
        ' call the commitchanges method
        manager.CommitChanges()
        manager.Dispose()
    End Sub

Microsoft Visual Studio 2010 Service Pack 1

Visual Studio 2010 SP1

Visual Studio 2010 SP1

Hello guys. I was wondering what do you think about the final version of the Visual Studio 2010 Service Pack 1?

I found that a lots of developers react negatively. Many of them even rolling back the SP1. They talk about incompatibilities with the SP1 release.

Please share your experience and opinion about the new Service Pack!!! Thanks

Download Link

MSDN Subscribers Here

A regex that matches all credit cards

Regular Expression For Credit Card Numbers

Regular Expression For Credit Cards

This is a regular expression that validates all credit card numbers including VISA, MASTER, AMEX and DISCOVERY! ^((4\d{3})|(5[1-5]\d{2})|(6011)|(34\d{1})|(37\d{1}))-?\d{4}-?\d{4}-?\d{4}|3[4,7][\d\s-]{15}$

<asp:RegularExpressionValidator ID="CreditCardValidator" runat="server" 
   ControlToValidate="CreditCardNumber" Display="Static" 
   ErrorMessage="Please enter valid card number" 
   ValidationExpression="^((4\d{3})|(5[1-5]\d{2})|(6011)|(34\d{1})|(37\d{1}))-?\d{4}-?\d{4}-?\d{4}|3[4,7][\d\s-]{15}$"  
  ValidationGroup="CustomSignup" Text="*" />

Conversion from Currency into English Words

Currency into Words

Currency into Words

I often need to convert the amounts into words when i create reports, checks and stuff. I found that the following recursive functions do the job perfectly. Most of the examples you can find out there are too long and confusing. This one seems to be shortest and str8 forward. Please check it out:

Read the rest of this entry »

Happy New Year 2011

Happy New Year 2011

Happy New Year 2011

 

 

may the New Year begin on a prosperous note! To all ASP.NET developers and their families! Cheers!!!

 

 

SQL Rounding Up Issue

often people complain about rounding up decimal values. The first question they ask is why SQL Server truncates the decimals which is silly because it happens in the code-behind.

For instance, say that you have a field of decimal datatype with precision 5 and scale 2 – decimal(5, 2)
Now if you don’t define precision of the output parameter the value will be rounded up. e.g. 0.99 becomes 1

CREATE PROCEDURE mySP
(
     @MyDecValue decimal(5, 2) output
)
AS
     SELECT @MyDecValue = MyDecField FROM MyTable WHERE Foo=1
Dim command As SqlCommand = connection.CreateCommand
command.CommandText = "mySp"
command.Parameters.Add("@MyDecValue", SqlDbType.Decimal, 5).Direction = Output

now if you execute the command the value will be as mentioned rounded up .. meaning, 0.99 becomes 1

You can solve it if you Define the precision and scale of the parameter e.g.

Dim command As SqlCommand = connection.CreateCommand
command.CommandText = "mySp"
Dim decimalsparam As New SqlParameter
decimalsparam.Direction = ParameterDirection.Output
decimalsparam.ParameterName = "@MyDecValue"
decimalsparam.Precision = 5
decimalsparam.Scale = 2
decimalsparam.Size = 5
 
command.Parameters.Add(decimalsparam)
command.ExecuteNonQuery()

DXperience v2010 vol 2 Review

Hi guys, this is my second review of these controls, and it will be quite different than the first.

A few months ago I was engaged by a client to develop a web based application. He asked me (I guess they all ask the same) to make it good looking and attractive. The first thing I thought of when I heard this was “I must renew my DXperience subscription”. And now I am glad I did that.

Before I continue, I would like to say something to those readers who are totally new to DXperience. Guys, we all know that one of the more frustrating things for the ASP.NET developers is designing the good looking application. Well folks, your troubles are over! The DXperience takes much of the agony out of developing and designing an outstanding web application.

Here we go! Read the rest of this entry »

AddHandler Statement

A very basic tutorial on AddHandler Statement. In this project we used it to prevent a non-numerical values to be entered in the textbox controls.

You may also choose the event handler for each control from Designer.
Just select all the controls you want to add the same Event Handler to.
Then from the Events view in Properties panel double click KeyPress and finally add the code that you want to apply to the selected controls.
Note: This approach can’t be used always instead AddHandler statement.

Merry Christmas and Happy New Year !!!

Happy Hollidays

Happy Hollidays

May this Christmas be bright and cheerful and may the New Year begin on a prosperous note! To all ASP.NET developers and their families! Cheers!!! :)

ASP.NET Exception – Invalid postback or callback argument

Invalid postback or callback argument

Invalid postback or callback argument

I’ve read many different suggestions for the Invalid postback or callback argument exception but, most of them do not work.
Some people will suggest to add your code inside If Not Page.IsPostBack Then block, other will tell you to set EnableEventValidation to false which is not serious at all. Even the compiler suggests ClientScriptManager.RegisterForEventValidation method but in most of the situations these will not work.

One is for certain: This specific exception is mostly thrown when you use a Master page!!!

Add the same javascript attributes to the very same server control out of the master page and you’ll see that it is working just fine.
Read the rest of this entry »

Bind DataList to DataView Without Using Database

Bind Datalist without DB

Bind Datalist without DB

This is going to be pretty easy so i will not bother you explaining things.
Just Download the Code Sample (sample images included) and you will figure out the rest of it, analyzing the code.
Generally speaking, it gets all *.jpg images from the given folder and display in the DataList control.


Live Example For Binding DataList Without Database (List of Images)

The Source Code Can be Downloaded From Here