Dynamic server controls using XML and XSLT

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

Guest

Hi Guys,

I am generating dynamic server controls using XML and
XSLT. With this I am generating two buttons which when
clicked redirect the page to a different page.

Here is my "checkout" button which is generated
dynamically looks something like this

<input type="image" name="checkout" id="checkout"
onClick="checkout_Click" src="images/checkout.jpg"
border="0" />

I have created code for the onClick event of the button in
the code-behind file, which looks like

public void checkout_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Response.Write("Checkout clicked!");
Response.Redirect("checkout.aspx");
}

Now when I run the application, I can get my buttons
displayed properly but when button is clicked I get a
runtime script error saying:

checkout_Click not defined.

I want to mention again that the code which handles the
onClick event (checkout_Click) is written in the code-
behind file. Somehow this is not being recognized by
the .aspx file. Can anyone give me pointers on how to make
this recognise my code-behind methods?

Thanks in advance
 
HI !

If the code that handles the event is in your code-behind
module (.vb), I strongly suspect it will require the
control to be defined.

Here is how VS.Net defines a control if you were to drag
it from the toolbox with the designe :

Protected WithEvents imgAddItem As
System.Web.UI.WebControls.ImageButton

Now, I am not sure it will work as your control does not
exist as design time... but it the ids (names) match, it
should.

Maybe not THE solution but a pointer...!

Hope this helps,

Ben
 
Back
Top