I know his old message to answer. Even the guy who posted this question found some solution to solve his question ............. but last night yesterday I faced the same difficulty so I came with a workaround that works on my case ...
I have 2 pages Page1.aspx and Page2.aspx I have Button1 and Button2 on page1.aspx now that the script is when I redirect to the page. ASP.NET, I want to access the Page1.aspx controls, which is called the previous page ..... So I use the PostBackURL buttons, but in this case I did not get the Click event on CodeBehind ........ since I have to solve this problem ............. What I did was that I set Button2.PostBackURL = "Page2.aspx", and when the Button1 Click event fires, I I register the start of the script that triggers the Button2.click event, so now I get the previous control page ..........
Here is the code ..... if someone is looking for the same functionality ............ they will be helped in a sense ........
Aspx Code
<asp:Button ID="btnSave" runat="server" Style="font-weight: 700" Text="Save" onclick="btnSave_Click" />
Code-behind
protected void btnSave_Click(object sender, EventArgs e){ try { StringBuilder objStringBuilder = new StringBuilder(); objStringBuilder.AppendLine("<script type='text/javascript' language='javascript'>"); objStringBuilder.AppendLine("document.getElementById('" + btnHidden.ClientID + "').click();"); objStringBuilder.AppendLine("</script>"); ClientScript.RegisterStartupScript(Page.GetType(),"Key1", objStringBuilder.ToString()); } catch (Exception ex) { throw ex; }}
Respectfully,
source share