1

I want to know if I could add a button click event after response.redirect().

protected void lnkEdit_Click(object sender, EventArgs e)
{
     LinkButton lnkEdit = (LinkButton)sender;
     string sno = lnkEdit.CommandArgument;
     Response.Redirect(string.Format("HomePage.aspx?eid={0}", sno));
}

this is my code. I want to redirect to a page which comes after clicking a button present in HomePage.aspx page without changing the url.

शेखर
  • 17,412
  • 13
  • 61
  • 117
Aravinda
  • 19
  • 1

2 Answers2

2

Your question is not exactly clear.

If you want to redirect to other page without changing the url you can use:

Server.Transfer(string.Format("HomePage.aspx?eid={0}", sno));

Here is server transfer documentation.

You can't add button click event after system Redirect. The execution of current page will be terminated after Redirect. If you want to execute something after redirecting, you can redirect to page with specific query param and on loading of the redirected page, execute wanted logic if the param is true.

mybirthname
  • 17,949
  • 3
  • 31
  • 55
0

Try this

public void Button1_Click(object sender, System.EventArgs e) 
{ 
        string sno = lnkEdit.CommandArgument;
        if(sender)
        Response.Redirect("HomePage.aspx?eid=" + sno);
}
SanyTiger
  • 666
  • 1
  • 8
  • 23