F5 problem..asp.netWhenever we press f5 insert query between page execution whole page execute again.Solution for this1) Capcha2)Maintaining session state and viewstateHow to maintain session and view stateprotected void Page_PreRender(Object sender, EventArgs e){ViewState["update"] = Session["update"];}protected void Page_Load(object sender, EventArgs e){if (!IsPostBack){Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());//to avoid problem of refresh frm Browser}}protected void btnSubmit_Click(object sender, ImageClickEventArgs e){if (Session["update"].ToString() == ViewState["update"].ToString()){//CodeSession["update"] = Server.UrlEncode(System.DateTime.Now.ToString());}}if user press f5 again then the buttonclick will execute again but it will not enter inif (Session["update"].ToString() == ViewState["update"].ToString())bcoz now session["update"] value has change.
0 comments:
Post a Comment