Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. F5 Refersh/Button Click [modified]

F5 Refersh/Button Click [modified]

Scheduled Pinned Locked Moved ASP.NET
csharpjavascripthtmlasp-netdesign
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amit Kumar G
    wrote on last edited by
    #1

    When an user clicks on a button click event and after the event got executed, if he hits on F5 key or Refresh button, the same button click event executes once again. How i can avoid this in ASP.Net 2.0.? Moreover i clear all the controls, so that it should fire javascript for mandatory fields. Instread of that it is rerading the values from cache..... I tried Button, HTML Submit and as well as ImageButton....But same behaviour.... Source Code: public partial class RepeaterFormControl : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { GetDataFromDatabase(); if (!(IsPostBack)) { Button1.Attributes.Add("onclick", "return ValidateInput();"); } } private void GetDataFromDatabase() { SQLDataAccessHelper daHelper = new SQLDataAccessHelper(); this.Repeater1.DataSource=daHelper.ExecuteReader(CommandType.StoredProcedure, "GetFormViewData"); this.Repeater1.DataBind(); } protected void clearControls() { ((TextBox)(FormView1.FindControl("TxtFName"))).Text = ""; ((TextBox)(FormView1.FindControl("TxtLName"))).Text = ""; ((TextBox)(FormView1.FindControl("TxtEmail"))).Text = ""; ((TextBox)(FormView1.FindControl("TxtDob"))).Text = ""; } protected void btnSave_Click(object sender, ImageClickEventArgs e) { String sFname = ((TextBox)(FormView1.FindControl("TxtFName"))).Text.ToString(); String sLname = ((TextBox)(FormView1.FindControl("TxtLName"))).Text.ToString(); String sEmail = ((TextBox)(FormView1.FindControl("TxtEmail"))).Text.ToString(); string sDOB = ((TextBox)(FormView1.FindControl("TxtDob"))).Text.ToString(); String sCountry = ((DropDownList)(FormView1.FindControl("CmbCountry"))).SelectedItem.Text.ToString(); SQLDataAccessHelper daHelper = new SQLDataAccessHelper(); IDataParameter[] objparam; objparam = daHelper.GetSpParameterSet("AddFormViewData"); objparam[0].Value = sFname; objparam[1].Value = sLname; objparam[2].Value = sEmail; objparam[3].Value = sDOB; objparam[4].Value = sCountry; daHelper.ExecuteNonQuery("AddFormViewData", objparam); GetDataFromDatabase(); clearControls(); sFname = ""; sLname = ""; sEmail = ""; sDOB = ""; } } And ASPX code....

    A 1 Reply Last reply
    0
    • A Amit Kumar G

      When an user clicks on a button click event and after the event got executed, if he hits on F5 key or Refresh button, the same button click event executes once again. How i can avoid this in ASP.Net 2.0.? Moreover i clear all the controls, so that it should fire javascript for mandatory fields. Instread of that it is rerading the values from cache..... I tried Button, HTML Submit and as well as ImageButton....But same behaviour.... Source Code: public partial class RepeaterFormControl : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { GetDataFromDatabase(); if (!(IsPostBack)) { Button1.Attributes.Add("onclick", "return ValidateInput();"); } } private void GetDataFromDatabase() { SQLDataAccessHelper daHelper = new SQLDataAccessHelper(); this.Repeater1.DataSource=daHelper.ExecuteReader(CommandType.StoredProcedure, "GetFormViewData"); this.Repeater1.DataBind(); } protected void clearControls() { ((TextBox)(FormView1.FindControl("TxtFName"))).Text = ""; ((TextBox)(FormView1.FindControl("TxtLName"))).Text = ""; ((TextBox)(FormView1.FindControl("TxtEmail"))).Text = ""; ((TextBox)(FormView1.FindControl("TxtDob"))).Text = ""; } protected void btnSave_Click(object sender, ImageClickEventArgs e) { String sFname = ((TextBox)(FormView1.FindControl("TxtFName"))).Text.ToString(); String sLname = ((TextBox)(FormView1.FindControl("TxtLName"))).Text.ToString(); String sEmail = ((TextBox)(FormView1.FindControl("TxtEmail"))).Text.ToString(); string sDOB = ((TextBox)(FormView1.FindControl("TxtDob"))).Text.ToString(); String sCountry = ((DropDownList)(FormView1.FindControl("CmbCountry"))).SelectedItem.Text.ToString(); SQLDataAccessHelper daHelper = new SQLDataAccessHelper(); IDataParameter[] objparam; objparam = daHelper.GetSpParameterSet("AddFormViewData"); objparam[0].Value = sFname; objparam[1].Value = sLname; objparam[2].Value = sEmail; objparam[3].Value = sDOB; objparam[4].Value = sCountry; daHelper.ExecuteNonQuery("AddFormViewData", objparam); GetDataFromDatabase(); clearControls(); sFname = ""; sLname = ""; sEmail = ""; sDOB = ""; } } And ASPX code....

      A Offline
      A Offline
      Amit Kumar G
      wrote on last edited by
      #2

      Here is the reply http://aspalliance.com/articleViewer.aspx?aId=687&pId=-1 Thanks!!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups