Posts Tagged ‘ ASP.NET ’

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

Session with ASP.NET(C#)

if you are new with session, you are in the right place. Here, I will try to put together some code snippets to show various uses of Session. Let’s start with how to assign a Integer value in Session followed by how to retrieve it.


// Assign "userCode" variable to Session  
int userCode = 7;
Session.Add("UserCode", userCode);

//Retrieve "userCode" from Session
int userCode;
userCode= (int)Session["UserCode"];

Continue reading

Crystal Report in ASP.NET

Using Crystal Report in ASP.NET is not a big deal. If you have Report (.rpt) File ready, you can use it in your Web Page straight way.

# First of all, add a CrystalReportViewer to your Page.
# In the Page_Init Event of your Page, attach your Report (.rpt) File and set Data Source for it.
# Finally, set CrystalReportViewer Report Source.
Continue reading