469,903 Members | 2,287 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

passing values to custom user control from dropdownlist

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" >
<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"
<asp:ListItem Value="null" Selected="True">Select your skin from the
<asp:ListItem Value="default">Default</asp:ListItem>
<asp:ListItem Value="green">Green</asp:ListItem>
<asp:ListItem Value="red">Red</asp:ListItem>
<asp:Label id=Label1 style="Z-INDEX: 102; LEFT: 49px; POSITION: absolute;
TOP: 253px" runat="server" Width="264px"></asp:Label>

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 +=

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.

/// <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_SelectedInd exChanged);
this.Load += new System.EventHandler(this.Page_Load);


Nov 17 '05 #1
0 1745

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Mark | last post: by
9 posts views Thread by james.e.coleman | last post: by
7 posts views Thread by Girish | last post: by
reply views Thread by scott blood | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.