I'm trying to get a textbox to trigger it's textchanged event and post back via atlas - my code is as follows:
<atlas:ScriptManagerID="sm1"runat="server"EnablePartialRendering="true"/>
<atlas:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:TextBoxID="TextBox1"runat="server"OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTriggerControlId="TextBox1"EventName="TextChanged"/>
</Triggers>
</atlas:UpdatePanel>
It doesn't work! Is this something that should work? I've tried also doing it with a timer which does create a postback, but my textbox loses it's focus everytime.
I've tried looking for posts relating to this but the search functionality on these forums doesn't seem to allow you to restrict searches to specific forums any more.
I wonder if anyone else has tried this or has any suggestions?
Thanks
hello.
i might be wrong, but i think that the trigger should only be used to refresh a panel based on the change of a property or event of another control that is placed *outside* of the updatepanel. when i look at your code, i see that the textbox is inside of the panel. in this case, i think that you only need to set up the textchanged event (btw, don't forget to set the autopostback prop of the textbox to true or the event won't fire!)
I've tried my code both with and without a trigger, and with the text box outside and inside of the update panel - none of these work - in all cases it expects the Return key to be pressed to trigger the postback.
Has anyone got any ideas what I'm doing wrong here, or is this functionality not present?
Think we need ScottGu to the rescue?
hello again.
have you set the autpostback property to true on the textbox? if you don't set that property you won't get an automatic postback when the value of the control is changed.
Yes, autopostback is set - but it only triggers when I press return. I'd hope if would trigger the textchanged event whenever a key was pressed in the text box and cause an Atlas postback.
Also I see on Scott's examples that he is able to directly reference a control that's inside the control template - I had to use FindControl to get to mine - any idea why this is?
I'd be grateful if someone could try this and see if I'm doing something wrong - here's my code:
<formid="form1"runat="server">
<atlas:ScriptManagerID="sm1"runat="server"EnablePartialRendering="true"/>
<asp:TextBoxID="TextBox1"runat="server"OnTextChanged="TextBox1_TextChanged"AutoPostBack="True"></asp:TextBox>
<atlas:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<h1>
<asp:LabelID="Label1"Text="Waiting for first postback"runat="server"></asp:Label>
</h1>
</ContentTemplate>
</atlas:UpdatePanel>
</form>
hello again.
well, the textchanged event only fires when the textbox looses its focus. so, if you hit tab after changing the value of the textbox you should also get a postback.
regarding your second question about getting a control, can you give us more info on what you're trying to do?
thanks.