Wednesday, March 21, 2012

dropdownlist

Hello All,

I have three dropdownlists and a textbox on my web page. The dropdownlists display the Day/Month/Year respectively.

I set the dropdownlists to display today's date when the page loads and the textbox displays the values from the dropdownlists as a single string value.

How can i dynamically change the dates in the dropdownlist for example ( instead of december 2007 to december 2008)and have the new changes displayed in the textbox?

The easiest way is to put your textbox inside an update panel like this:

 

<asp:UpdatePanelID="updPanel"runat="server"UpdateMode="Conditional">

<ContentTemplate>

<asp:TextBoxID="txtDate"runat="server"/>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlID="DropDownList"EventName="SelectedIndexChanged"/>

</Triggers>

</asp:UpdatePanel>

Now in the SelectedIndexChanged event handler, just set the textbox to the new text. That's it!


Thanks oswaldorb,

It works but not as i want it to.

I would like the default date to be the current date for example 13/12/2007 when the page loads initially.

But when i try to do change the default date, i get an error

Please help!

No comments:

Post a Comment