passing values to custom user control from dropdownlist

A

adam

i have custom user control and i'm trying to pass values to custom user
control......I need help it seems to me i cannot pass the value to user
control from dropdownlist. I have property in a control. In a default.aspx
page <SkinExample:Hello id="HelloControl" SkinName="red" runat="server" />
i can pass the value, it works fine, but from the dropdownlist in a
codebehind page i can't pass the value.

Could some one help me out with this.............Thanks






here is my default.aspx page look like
----------------------------------------------

<%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false"
Inherits="SkinExample._Default" %>
<%@ Register TagPrefix="SkinExample" Namespace="SkinExample"
Assembly="SkinExample" %>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" >
<html>
<head>
</head>
<body ms_positioning="GridLayout">
<form id=Form1 method=post runat="server">
<SkinExample:Hello id="HelloControl" runat="server" />
<asp:dropdownlist id=DropDownListSkins style="Z-INDEX: 101; LEFT: 21px;
POSITION: absolute; TOP: 79px" runat="server" width="228px"
autopostback="True">
<asp:ListItem Value="null" Selected="True">Select your skin from the
list</asp:ListItem>
<asp:ListItem Value="default">Default</asp:ListItem>
<asp:ListItem Value="green">Green</asp:ListItem>
<asp:ListItem Value="red">Red</asp:ListItem>
</asp:dropdownlist>
<asp:Label id=Label1 style="Z-INDEX: 102; LEFT: 49px; POSITION: absolute;
TOP: 253px" runat="server" Width="264px"></asp:Label>
</form>
</body>
</html>

and codebehind page
-------------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace SkinExample
{
/// <summary>
/// Summary description for _Default.
/// </summary>
public class _Default : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1;
protected System.Web.UI.WebControls.DropDownList DropDownListSkins;

private void Page_Load(object sender, System.EventArgs e)
{
}

private void DropDownList1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
Control myCC = Page.FindControl("HelloControl");
((Hello)myCC).SkinName +=
DropDownListSkins.SelectedItem.Value.ToString();

Label1.Text = "";
Label1.Text += DropDownListSkins.SelectedItem.Value.ToString();
}


#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.DropDownListSkins.SelectedIndexChanged += new
System.EventHandler(this.DropDownList1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top