ParseControl

Discussion in 'ASP .Net Building Controls' started by Matt Crego, Sep 30, 2003.

  1. Matt Crego

    Matt Crego Guest

    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?
     
    Matt Crego, Sep 30, 2003
    #1
    1. Advertising

  2. Matt Crego

    Andy Smith Guest

    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

    >-----Original Message-----
    >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?
    >.
    >
     
    Andy Smith, Oct 1, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthias Lohrer

    Page.ParseControl drives me crazy

    Matthias Lohrer, Jul 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,753
    Matthias Lohrer
    Jul 8, 2003
  2. Matthias Lohrer

    Using Validation Controls with Page.ParseControl

    Matthias Lohrer, Jul 29, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,596
    Satish Appasani
    Jul 29, 2003
  3. Chris Simeone

    .NET ParseControl() method problem

    Chris Simeone, Dec 10, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    2,355
    Chris Simeone
    Dec 10, 2003
  4. Jeremy McPeak

    ParseControl()

    Jeremy McPeak, Dec 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,919
    Rick Strahl [MVP]
    Dec 21, 2003
  5. Chris Simeone

    Is this a ParseControl bug?

    Chris Simeone, Dec 22, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    645
    Patrice Scribe
    Dec 23, 2003
Loading...

Share This Page