page.aspx
<script type="text/javascript"> $(function () { //javascript or jQuery event $("#MyButton").click(function() { <%=PostBackString %> //this will insert our postback code at runtime }); }); </script>
page.aspx.cs
protected string PostBackString; protected void Page_Load(object sender, EventArgs e) { //this gets the postback code that we will use on our aspx page PostBackString = Page.ClientScript.GetPostBackEventReference(this, "MyEventArgumentName"); if (IsPostBack) { //Check if the postback was caused by our event if (Request["__EVENTARGUMENT"] == "MyEventArgumentName") { //Do something } } }
0 comentarios:
Publicar un comentario