Archive for May, 2012

Javascript Confirmation with ASP.NET Validations

It was difficult for me to find out how to use submit confirmation while using ASP.NET validations in Web Form. This following one is the Java Script Function to be used.

   function ConfirmSubmit() {

        if (Page_IsValid) {

            return confirm('Do you want add this User?');

        return Page_IsValid;

Use it this way with your Submit Button.

onclientclick="return ConfirmSubmit();"

A Rahim Khan


StateServer Session Mode with Class (Object) ASP.NET

First of all, ASP.NET State Service is to be on to use StateServer Session.
Place this piece of code in your Web.Config File.

sessionState mode="StateServer" stateConnectionString="tcpip=" cookieless="false" timeout="120"

Now you can start using StateServer Session, rest of the steps are same all kind of Sessions.

However, if you are storing any Class’s Object in StateServer Session, this particular class requires Serialization. Have a look at this User Class, it’s object can be stored in StateServer Session. Continue reading

Get Web User IP Address for Local Network Web Application

This is going to work only for Local network Web Application, it will return proxy’s IP if anyone using Proxy to connect your Web Application.

string userIpAddress = Request.UserHostAddress.ToString();

A Rahim Khan

Set Value to ASP.NET Password Mode TextBox

You can’t directly set value for Password Mode TextBox like Normal Single/Multiline TextBox. You got to do it like

userPasswordTextBox.Attributes["value"] = "PASSWORD";
retypePasswordTextBox.Attributes["value"] = "RETYPE PASSWORD";

A Rahim Khan