How do you go about accessing and declaring events for thosecontrols that are nested within the accordion control (for example) ?
ie.I want to have the following Sub for a txtBox that is nested within anaccordionpane? I understand to get to the control's properties you canuse the .FindControls method on the accordion pane, but how do Ideclare a control's event like below?
Protected SubtxtBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)Handles txtBox.TextChanged
...
End Sub
<atlasToolkit:AccordionPane ID="AccordionPane1" runat="server">
<Header><a href="http://links.10026.com/?link=" onclick="return false;"class="accordionLink">5. References</a></Header>
<Content>
<asp:TextBox ID="txtBox" runat="server" CssClass="txtBox" />
</Content>
</atlasToolkit:AccordionPane>
Thanks
You should be able to wire them up like you normally would through either HTML or in code.
via HTML: Just add TextChanged="txtBox_TextChanged" to your TextBox tag.
programmatically: Use FindControls to get the control and then (C#) objTextBoxRef.TextChanged += EventHandler(txtBox_TextChanged);
How would I do it in VB.Net ?
In HTML I have, for example:
<asp:TextBox ID="txtBox" OnTextChanged="txtBox_TextChanged" runat="server" CssClass="txtBox" />
on the .vb code page I then have:
Public WithEvetns txtBox as TextBox
Sub txtBox_TextChanged(ByValsender As Object, ByVal e As System.EventArgs) HandlestxtBox.TextChanged
xtBox.Text = Format(txtBoxy.Text, "currency")
End Sub
But I get the following error:
Error 1 Method 'Sub txtBoxTextChanged()' does not have thesame signature as delegate 'Delegate Sub EventHandler(sender As Object,e As System.EventArgs)'.
excuse my typos...in my last post.Actually my errors window was just not refreshing.
But still, when I run it, the textchanged event does not fire at all...
...nevermind. i did not have the attribute "AutoPostBack = True" in my tag..I hate it when I'm such a beginner...
No comments:
Post a Comment