locked
Maintain variable value (used to store password) after postback RRS feed

  • Question

  • User1505411267 posted

    Hello Experts,

     

    I am using a modal popup control (AJAX) to capture UserID, Password & DomainName from the user. These credentials are further used in C# code to do a WMI query to remote servers. The values are then assigned/stored in String variables in C# code.

    string Passwrd = txtPassword.Text;
    string UID = txtUserID.Text;
    string DomainName = ddlDomain.SelectedValue;

    The problem I am facing is: after PostBack, these variables are loosing their values and users of this website need to provide the credentials after each postback.

     

    How do I preserve the values for the variables in each user sesstion?

    NOTE: I can not use viewstate for security reasons.

    Tuesday, August 16, 2011 5:48 AM

Answers

  • User377791177 posted

    assing them to Session variables.

    Session["Passwrd"] = txtPassword.Text;
    Session["UID"] = txtUserID.Text;
    Session["DomainName"] = ddlDomain.SelectedValue;
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 16, 2011 5:57 AM

All replies

  • User377791177 posted

    assing them to Session variables.

    Session["Passwrd"] = txtPassword.Text;
    Session["UID"] = txtUserID.Text;
    Session["DomainName"] = ddlDomain.SelectedValue;
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 16, 2011 5:57 AM
  • User510401362 posted

    Hi,

    Yes, in session variable you can preserve the value after postback but it would be server side.. but if you preserve at client side then use the Hidden field or cookies for the same

    Tuesday, August 16, 2011 6:02 AM
  • User-739396301 posted

    You could use viewstate or session objects to persist items. One of the feature given by microsoft is "User Interface Process Application Block" This will persist the values and also restores them after the postback

    Tuesday, August 16, 2011 9:26 AM