473,396 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

}
#endregion
}
}



Nov 17 '05 #1
0 1887

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mark | last post by:
Hi, I have created a custom user control that includes a dynamically created drop down list populated with data from a database. The control class contains a BindList routine that is used to...
5
by: Bryan Ax | last post by:
I have a page that has two copies of the same control in it. The control is: BorrowerControl the two references to it in the page are bControl1 cobControl1
9
by: james.e.coleman | last post by:
Hello, I have created a custom dropdownlist that is used multiple times within a single page. When trying to set the values of the controls with the page in which they are being used, they all...
7
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid,...
2
by: Pipo | last post by:
Nobody knows how to get the values provided in the client can be read in the user-control? If have made a Web Custom Control with 2 textboxes and 1 dropdownlist. The user fills in my control (the...
1
by: Joe | last post by:
Hello All, I have a user control which is composed of a label and a dropdownlist. In my code I add the user control to a placeholder on the webform. Now I want to be able to retrieve the...
5
by: Alan Silver | last post by:
Hello, I have a products page that takes a product ID in the query string. Based on the product details (from a database), the page then loads up one of a number of custom controls, calls a...
0
by: scott blood | last post by:
Hey all, I have tried posting this question in the relevant Asp.net newsgroups, but have unfortunatly had no reply, so hopefully someone can help me in here. I have created a custom webcontrol...
4
by: pankajsingh5k | last post by:
Hi guys, These question is for all the experts... Please help me before my brain explodes The problem is again with the formview control.. I have a formview and i have to use it that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.