master-content page problem
-
i have a master page n a content page..in content page i have a datalist and two button....while running this it trows an exception "Control 'ctl00_ContentPlaceHolder1_btnPrev' of type 'Button' must be placed inside a form tag with runat=server." so i add the code in content page's load event
System.IO.StringWriter stringwriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlwriter = new System.Web.UI.HtmlTextWriter(stringwriter); this.pnl1.RenderControl(htmlwriter); string s = stringwriter.ToString(); public override void VerifyRenderingInServerForm(Control control) { return; }
EnableEventValidation="false"....now its working but the problem is this..the click-event of the buttons of content page are not working...please someone help -
i have a master page n a content page..in content page i have a datalist and two button....while running this it trows an exception "Control 'ctl00_ContentPlaceHolder1_btnPrev' of type 'Button' must be placed inside a form tag with runat=server." so i add the code in content page's load event
System.IO.StringWriter stringwriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlwriter = new System.Web.UI.HtmlTextWriter(stringwriter); this.pnl1.RenderControl(htmlwriter); string s = stringwriter.ToString(); public override void VerifyRenderingInServerForm(Control control) { return; }
EnableEventValidation="false"....now its working but the problem is this..the click-event of the buttons of content page are not working...please someone helpYou lose viewstate when you add dynamic controls, unless you do it before page_load. You'd do better to fix your tag so that it works when placed in the content page. Your content was obviously broken or you would not have got an error
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
You lose viewstate when you add dynamic controls, unless you do it before page_load. You'd do better to fix your tag so that it works when placed in the content page. Your content was obviously broken or you would not have got an error
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
but i have done...
<%@ Page Language="C#" MasterPageFile="~/MasterPage2.master" AutoEventWireup="true" EnableViewState="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" EnableEventValidation="false" %>
..still my button click event is not working...please help