Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Mantain ViewState (http://www.velocityreviews.com/forums/t775607-mantain-viewstate.html)

Jonathan 03-10-2005 12:25 PM

Mantain ViewState
 
Hello,
I'm writed a WebCustomControl but I can't mantain the viewstate. This is the
code of my WebCustomContol:

public class WebCustomControl1 : System.Web.UI.WebControls.WebControl,
IPostBackEventHandler
{
public event EventHandler DoPostBack;
protected override void Render(HtmlTextWriter output)
{
output.Write(GetControlHTML());
}
private string GetControlHTML()
{
StringWriter TextBoxWriter = new StringWriter();
HtmlTextWriter ControlWriter = new HtmlTextWriter(TextBoxWriter);
TextBox box = new TextBox();
box.ID = "txtViewState";
if(ViewState["txtViewState"] == null)
ViewState.Add("txtViewState","Testeando");
box.Text = (string)ViewState["txtViewState"];
box.RenderControl(ControlWriter);
Button button = new Button();
button.Text = "DoPostBack";

button.Attributes.Add("onclick",Page.GetPostBackCl ientEvent(button,"doPostBa
ck"));
button.RenderControl(ControlWriter);
return TextBoxWriter.ToString();
}
public void RaisePostBackEvent(string eventArgument)
{
if(eventArgument == "doPostBack")
{
if(this.DoPostBack != null)
this.DoPostBack(this,EventArgs.Empty);
}
}
}

* The Page.EnableViewState is true

Somebody knows how is the correct way to mantain the ViewState?

Thanks!




All times are GMT. The time now is 07:12 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.