PC Review


Reply
Thread Tools Rate Thread

Custom Web Control - viewstate and event wiring questions

 
 
=?Utf-8?B?amVzc2UgamFtZXMgMjAyMA==?=
Guest
Posts: n/a
 
      18th Aug 2006
I cannot get viewstate nor can I wire up events to child controls... Any
thoughts are appreciated. Example code is below:

public class SelectCashFlowPeriods:Table
{
const int DROPDOWNWIDTH = 106;

protected DropDownList Period1;
protected Button SubmitSelection;

public SelectCashFlowPeriods()
{
}

protected override void RenderContents(HtmlTextWriter writer)
{
EnsureChildControls();

writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
Period1.RenderControl(writer);
writer.RenderEndTag(); // end td
writer.RenderEndTag(); // end tr

writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
SubmitSelection.RenderControl(writer);
writer.RenderEndTag(); // end td
writer.RenderEndTag(); // end tr
}

protected override void CreateChildControls()
{
Controls.Clear();

Period1 = new DropDownList();

SubmitSelection = new Button();
SubmitSelection.Text = "submit me";

Period1.AutoPostBack = true;
Period1.EnableViewState = true;
Period1.SelectedIndexChanged +=new
EventHandler(Period_SelectedIndexChanged);
Period1.Width = Unit.Pixel(DROPDOWNWIDTH);

Period1.Items.Add(new ListItem("select one", "0"));
Period1.Items.Add(new ListItem("one", "1"));
Period1.Items.Add(new ListItem("two", "2"));
Period1.Items.Add(new ListItem("three", "3"));

base.CreateChildControls();
}

protected virtual void Period_SelectedIndexChanged(object sender,
EventArgs e)
{
// do stuff
}
}

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Dynamically Loaded User Control Event Wiring Andrew Robinson Microsoft ASP .NET 5 28th May 2007 10:59 AM
Wiring up event to a dynamically generated control Sosh Microsoft ASP .NET 5 16th Nov 2005 01:10 PM
Custom Control Interfering with ViewState Chris Newby Microsoft ASP .NET 0 27th Feb 2005 09:35 PM
Missing Viewstate in Custom Control Mark Sisson Microsoft Dot NET 0 19th Jul 2003 12:35 AM
Missing Viewstate in Custom Control Mark Sisson Microsoft ASP .NET 0 19th Jul 2003 12:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:05 AM.