Click here to Skip to main content
15,915,804 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
inside cell when I used dynamic textbox for validation for only integer not string not able to validate showing u cant place in c# web application

showing the error

Control 'ctl12' of type 'RegularExpressionValidator' must be placed inside a form tag with runat=server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Control 'ctl12' of type 'RegularExpressionValidator' must be placed inside a form tag with runat=server.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Control 'ctl12' of type 'RegularExpressionValidator' must be placed inside a form tag with runat=server.]
   System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +8686387
   System.Web.UI.WebControls.BaseValidator.Render(HtmlTextWriter writer) +119
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19





and the i pasted like that

C#
string srate = "select case when b.ofc_20=0 and b.ofc_40=0 then b.ofc_bl else case when size1=1 then ofc_20 else case when size1=2 then ofc_40 end end end as ofc from tblsales sc,tblsubport b where sc.subport=b.subportid and sc.refid=' PKL107DEL'";
                                                SqlDataReader chrgdr = objconnection.getDataReader(srate, lblerror);
                                                chrgdr.Read();
                                                HtmlInputText itxt = new HtmlInputText();
                                                itxt.ID = "itxt";
                                                cnew.Controls.Add(itxt);
                                                RegularExpressionValidator validator = new RegularExpressionValidator();
                                                validator.ControlToValidate = itxt.ID;
                                                validator.ValidationExpression = "[0-9]";
                                               
                                                    validator.ErrorMessage = "enter numbers only";
                                               
                                                cnew.Controls.Add(validator);
Posted
Updated 10-Apr-11 21:31pm
v2

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

This message tells that the RegularExpressionValidator with id ctl12 is placed outside of the form tag. Place the control inside the form tag.
 
Share this answer
 
Hi,

In properties There is validate property just put * and in Button Event Properties there is also validate property will be there just u put * then u check it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900