Skip to content

Instantly share code, notes, and snippets.

@rousso
Created March 7, 2013 09:47
Show Gist options
  • Save rousso/5106837 to your computer and use it in GitHub Desktop.
Save rousso/5106837 to your computer and use it in GitHub Desktop.
This gist contains snippets that support the article at http://rousso.blogspot.com/2006/05/usesubmitbehavior-getpostbackeventrefer.html
<asp:detailsview id="DetailsView1" runat="server">
...
</asp:detailsview>
<asp:HyperLink ID="HyperLink1" runat="server" Text="HyperLink" />
<input id="Button1" type="button" value="button1" runat="server"/>
<asp:Button ID="Button2" runat="server" Text="Button2" />
HyperLink1.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(DetailsView1, "New$0", true);
Button1.Attributes.Add("onClick", Page.ClientScript.GetPostBackClientHyperlink(DetailsView1, "New$0", true));
Button2.UseSubmitBehavior = false;
Button2.OnClientClick = Page.ClientScript.GetPostBackEventReference(DetailsView1, "New$0");
<a id="HyperLink1" href="javascript:__doPostBack('DetailsView1','New$0')">HyperLink</a>
<input name="Button1" type="button" id="Button1" value="button" onclick="javascript:__doPostBack('DetailsView1','New$0')" />
<input type="button" name="Button2" value="Button" id="Button2" onclick="__doPostBack('DetailsView1','New$0'); __doPostBack('Button2','')" />
Button2.OnClientClick = Page.ClientScript.GetPostBackEventReference(DetailsView1, "New$0") + "; return;";
<input type="button" name="Button2" value="Button" id="Button2" onclick="__doPostBack('DetailsView1','New$0'); return;__doPostBack('Button2','')" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment