arguments in functions/buttons

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi there, I am using c#, not quite sure how to get an argument into an event.

protected void btnRedirect_Click (object sender, eventargs e) {

go to url newpage?id=[id i passed]

}


i know sender is whatever control invoked this code (e.g. button) but not
sure what the eventargs is for. I have a button which performs a click event.
But I want to send a value to the click event (an id to be passed in an url
redirection). How do I put this string into the argument list of the click
event?

I am also trying to put the id into the click in the html and this is
returning an error (asp server control not formed). The value I want to pass
comes from an asprepeater. what am i missing in the following?

<asp:ImageButton id="btnNext" ImageURL="~/images/but_next.gif" height="17px"
width="48px" onclick="btnViewClient_Click(<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>)" runat="server"/>

Thank you.
 
Don't do this with a normal button. Use a CommandButton instead. Then you
can set the CommandText property of it to whatever you want and access it
through the event handler.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
Back
Top