Archive for the ‘ ASP.NET ’ Category

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() {
    
        Page_ClientValidate();

        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();"

Thanks
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=127.0.0.1:42424" 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();

Thanks
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";

Thanks
A Rahim Khan

firing client validation before client confirmation in asp.net

Client Side Confirmation is simple one using Java Script, Just write this single line in OnClienClick Properties of your Submit Button and set up Client Confirmation Box at Button Click Event.


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

Now, when you have Java Script validation in your page this kind of Client Confirmation will create difficulties. More specifically, at Button Click Confirmation Box will will appear first, if client click Ok Button, Web Page will be submitted to server skipping Client Side Validation. Continue reading