Dynamic server controls using XML and XSLT

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
 
B

Ben

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top