Wednesday, March 21, 2012

Dropdownlist

I have just started using Atlas and I am having a little trouble changing the text of a label when a font is selected from a drop down list. When the font-family name is selected the entire dropdown list is moved into the label. Here is my code

C# code

protected

void Page_Load(object sender,EventArgs e)

{

if (!Page.IsPostBack)

{

DisplayLabel.Style.Clear();FontFamilyDropDownList.DataSource = System.Drawing.FontFamily.Families;

FontFamilyDropDownList.DataBind();

FontFamilyDropDownList.Items.Insert(0,

"Default");

}

}

protectedvoid FontFamilyDropDownList_SelectedIndexChanged(object sender,EventArgs e)

{

DisplayLabel.Text = FontFamilyDropDownList.SelectedValue;

}

ASP Code

<asp:LabelID="DisplayLabel"runat="server"Text="Test Atlas Controls"></asp:Label>

<atlas:UpdatePanelID="FontNameUpdatePanel"Mode="Conditional"runat="server"><Triggers><atlas:ControlEventTriggerControlID="FontFamilyDropDownList"EventName="SelectedIndexChanged"/></Triggers><ContentTemplate>

<asp:DropDownListID="FontFamilyDropDownList"runat="server"DataTextField="Name"OnSelectedIndexChanged="FontFamilyDropDownList_SelectedIndexChanged"AutoPostBack="true"></asp:DropDownList>

</ContentTemplate></atlas:UpdatePanel>

Any suggestions would be great

Thanks

Mike

Figured it out, needed to place the label inside of the ContentTemplate and remove the DropDownList for it to work.

No comments:

Post a Comment