Do you know not to use LinkButton?
  v1.0 Posted at 2/09/2016 4:06 AM by Tiago Araujo
If we want to refresh and data bind the same page from client side, we can use the javascript function calls "__doPostBack". We shouldn't fire this post back in LinkButton. Otherwise, there will be an error.
Figure: Right click the link with __doPostBack event  ​
Figure: New window with incorrect URL

<asp:Panel runat="server" ID="mUpdatePanel" OnLoad="mUpdatePanel_Load">
<asp:Label runat="server" ID="lblTime" />
<br />
<asp:GridView ID="gvList" runat="server" AutoGenerateColumns="false">
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<br />
ID:<asp:TextBox ID="txtID" runat="server"/>
Name:<asp:TextBox ID="txtName" runat="server"/>
protected void mUpdatePanel_Load(object sender, EventArgs e)
lblTime.Text = DateTime.Now.ToLongTimeString();
ArrayList mList = (ArrayList)ViewState["List"];
if (txtName.Text.Length > 0)
Client mClient = new Client();
mClient.ID = Int32.Parse(txtID.Text);
mClient.Name = txtName.Text;
ViewState["List"] = mList;
gvList.DataSource = mList;

Sample Code​​​

​​​<a href="javascript:__doPostBack('mUpdatePanel','');">Refresh</a>

Bad Code​

<input type="button" onclick="javascript:__doPostBack('mUpdatePanel','');" value="Refresh" />

Good Code​

We have a program called SSW Code Auditor to check for this rule.​

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address: