Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 9th, 2009, 08:44 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default RenderControl is Giving the Error.

hello friends,

I am looking for sending any server control in mail ..but I am getting the Error which is:

Control 'TextBox1' of type 'TextBox' must be placed inside a form tag with runat=server.

this is CODE BEHIND:

protected void Page_Load(object sender, EventArgs e)
{

TextBox1.Text = "Finishing";
StringBuilder SB = new StringBuilder();
StringWriter SW = new StringWriter(SB);
HtmlTextWriter HTW = new HtmlTextWriter(SW);
TextBox1.RenderControl(HTW);

}

this is ASPX page.

<body>
<form id="form1" runat="server">
<asp:TextBox runat="server" ID="TextBox1"></asp:TextBox>
</form>
</body>



thanks !!!
__________________
DPK..
 
Old June 12th, 2009, 02:43 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

First, disable event validation in the page directive.

HTML Code:
<%@ Page EnableEventValidation="false" Language="C#" ...
Then, try this:

Code:
protected void Page_Load(object sender, EventArgs e)
{
   TextBox1.Text = "Finishing";
 
   StringWriter sw = new StringWriter();
   HtmlTextWriter htw = new HtmlTextWriter(sw);       
   TextBox1.RenderControl(htw);
 
   string text = sw.ToString();      
 
}
public override void VerifyRenderingInServerForm(Control control)
{       
}
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error giving when i create the Subdomain Surjit Classic ASP Professional 0 April 18th, 2008 06:17 AM
mysql_num_rows() => Giving Error? Cybot MySQL 4 September 12th, 2006 12:07 PM
This piece of code is giving an error sourik C# 2 July 15th, 2006 09:18 AM
This piece of code is giving an error sourik Classic ASP Databases 1 July 14th, 2006 09:10 PM
excel export giving memory error msrnivas .NET Web Services 0 September 6th, 2004 12:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.