Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > passing values to custom user control from dropdownlist

Reply
Thread Tools

passing values to custom user control from dropdownlist

 
 
adam
Guest
Posts: n/a
 
      08-08-2003
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
}
}









 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Parameters to user control within another user control hmikki ASP .Net Web Controls 1 10-19-2007 02:00 AM
Custom User Control is not rendered inside another user control in a server table. Leeor Chernov ASP .Net 2 10-16-2005 08:35 AM
Passing values to a custom control Chris Kennedy ASP .Net Building Controls 5 06-26-2004 08:18 AM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM
Re: user control - passing values Steve C. Orr, MCSD ASP .Net 2 07-12-2003 09:12 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57