ParseControl

M

Matt Crego

What approaches has anyone found that would allow for
parsing of serverside events when using the
Page.ParseControl method? I currently have the following
snippet in an xsl file:

Login:<br/>
<asp:TextBox ID="userid" Runat="server" /><br/>
<asp:LinkButton ID="login" Runat="server"
OnServerClick="Login_Click" />

When I use the ParseControl method to parse it and add
this to the Page Controls Collection, it works fine, with
the exception of not including the OnServerClick as the
handler for this click event. It is sent to the client.

I have read an article which uses server-side code to look
for specific controls and manually add the event handlers
to each control. I do not know up front what the controls
are called, and which events would fire which handlers, so
this is not really possible to do in the code. Is there a
better or different way to do this?
 
A

Andy Smith

After the control is parsed, you would presumably have
access to the Attributes collection. From there, you could
cycle thru them, and pick out the ones that start
with "on". Then you could use reflection to see if that
control type has an event named the same. if it does, then
use a bit more reflection to look for the appropriate
method to connect with.

__
Andy Smith
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top