Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Using Control.Render() from a page with a MasterPage

Thread Tools

Using Control.Render() from a page with a MasterPage

Posts: n/a
I am trying to use the following code on a page with a master page.

System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htw = new HtmlTextWriter(sw);

// this throws the exception

I am using a ContentPlaceHolder and the form is on the MasterPage.

I get the following error message...
System.Web.HttpException was unhandled by user code
Message="Control 'ctl00_ContentPlaceHolder1_gridResults' of type
'GridView' must be placed inside a form tag with runat=server."
at System.Web.UI.Page.VerifyRenderingInServerForm(Con trol control)
at System.Web.UI.WebControls.GridView.Render(HtmlText Writer writer,
Boolean renderPanel)
at System.Web.UI.WebControls.GridView.Render(HtmlText Writer writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTe xtWriter writer,
ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at ExportData.ExportToExcel() in
c:\Work\SAGEAnalyzerGUI_2\App_Code\ExportData.cs:l ine 115
at ExportData.Export() in
c:\Work\SAGEAnalyzerGUI_2\App_Code\ExportData.cs:l ine 100
at PageMaster.ExportToExcel() in
c:\Work\SAGEAnalyzerGUI_2\PageMaster.master.cs:lin e 32
at FuelBurnResults.BtnExportExcelClick(Object sender, EventArgs e) in

Is there a way to call the Render() method and still use a MasterPage?



Reply With Quote

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
Changing a control on a masterpage that uses a second masterpage Torben Laursen ASP .Net 4 03-15-2008 03:27 AM
Masterpage change its masterpage mr t ASP .Net 0 08-29-2007 10:11 PM
MasterPages - take plain form, add MasterPage. MasterPage does NOT appear when run Randy Smith ASP .Net 9 04-14-2007 09:06 AM
MasterPage inheriting a MasterPage... is it possible? ThunderMusic ASP .Net 2 09-27-2006 07:57 PM
MasterPage -> Page -> MasterPage Code Access =?Utf-8?B?QWxleCBNYWdoZW4=?= ASP .Net 3 04-14-2006 12:34 PM