471,119 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,119 software developers and data experts.

dynamic form not validating on server

Hello,

I am trying to create a form dynamically. A very simple form with a textbox,
requiredvalidator and button.

Everything works fine on IE, but no server side validation occurs which
means the requiredfieldvalidator is ignored when using Netscape.

The code logic is:

'Declare a an html form i.e
Dim objForm As New HtmlForm
objForm.Attributes.Add("RunAt", "Server")

Create a table, tablerow and tablecell

Add a textbox and requirefieldvalidator to a cell
Add the cell to the row
Add the row to the table
Add a button to the table
Add the table to the form
Add the form to a placeholder control on the web page

Is there something I am missing? I tried adding the requiredfieldvalidator
control to the validators collection of the page, ie
Me.Validators.Add(validatorcontrol)
as described in http://forums.asp.net/577243/ShowPost.aspx but that makes no
difference.

I have switched off clientside validation and get the same result in IE.

Is there something simple I am missing or do I really need to take a serious
look at creating user controls in asp.net?

Best Regards,

Steve Bugden
Feb 28 '06 #1
5 1219
At which stage of the page's lifecycle are you adding your form? Dynamically
added controls need to be added during the Page.Init stage to maintian their
ViewState upon postback.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Steve Bugden" wrote:
Hello,

I am trying to create a form dynamically. A very simple form with a textbox,
requiredvalidator and button.

Everything works fine on IE, but no server side validation occurs which
means the requiredfieldvalidator is ignored when using Netscape.

The code logic is:

'Declare a an html form i.e
Dim objForm As New HtmlForm
objForm.Attributes.Add("RunAt", "Server")

Create a table, tablerow and tablecell

Add a textbox and requirefieldvalidator to a cell
Add the cell to the row
Add the row to the table
Add a button to the table
Add the table to the form
Add the form to a placeholder control on the web page

Is there something I am missing? I tried adding the requiredfieldvalidator
control to the validators collection of the page, ie
Me.Validators.Add(validatorcontrol)
as described in http://forums.asp.net/577243/ShowPost.aspx but that makes no
difference.

I have switched off clientside validation and get the same result in IE.

Is there something simple I am missing or do I really need to take a serious
look at creating user controls in asp.net?

Best Regards,

Steve Bugden

Feb 28 '06 #2
Hi Phillip,

Thanks for the reply.

I moved the dynamically added controls from teh page_load event to the
Page_Init event and it now works fine. ie the requiredfieldvvalidator kicks
in if a required field is missing.

But I would also like to display a simple user message (rather than the
form), if the form is valid. On the postback, in the Page_Init event after
calling Me.Page.Validate, Me.Page.IsValid is set true, (Although this works
correctly in the page_load event)

How can I stop the form displaying if the it is valid?

Best Regards,

Steve

"Phillip Williams" wrote:
At which stage of the page's lifecycle are you adding your form? Dynamically
added controls need to be added during the Page.Init stage to maintian their
ViewState upon postback.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Steve Bugden" wrote:
Hello,

I am trying to create a form dynamically. A very simple form with a textbox,
requiredvalidator and button.

Everything works fine on IE, but no server side validation occurs which
means the requiredfieldvalidator is ignored when using Netscape.

The code logic is:

'Declare a an html form i.e
Dim objForm As New HtmlForm
objForm.Attributes.Add("RunAt", "Server")

Create a table, tablerow and tablecell

Add a textbox and requirefieldvalidator to a cell
Add the cell to the row
Add the row to the table
Add a button to the table
Add the table to the form
Add the form to a placeholder control on the web page

Is there something I am missing? I tried adding the requiredfieldvalidator
control to the validators collection of the page, ie
Me.Validators.Add(validatorcontrol)
as described in http://forums.asp.net/577243/ShowPost.aspx but that makes no
difference.

I have switched off clientside validation and get the same result in IE.

Is there something simple I am missing or do I really need to take a serious
look at creating user controls in asp.net?

Best Regards,

Steve Bugden

Feb 28 '06 #3
Hi Phillip,

Sorry for such a stupid question, I just cleared the placeholder in the
page_load event if the form is valid.

Thanks once again for you help,

Steve Bugden.

"Steve Bugden" wrote:
Hi Phillip,

Thanks for the reply.

I moved the dynamically added controls from teh page_load event to the
Page_Init event and it now works fine. ie the requiredfieldvvalidator kicks
in if a required field is missing.

But I would also like to display a simple user message (rather than the
form), if the form is valid. On the postback, in the Page_Init event after
calling Me.Page.Validate, Me.Page.IsValid is set true, (Although this works
correctly in the page_load event)

How can I stop the form displaying if the it is valid?

Best Regards,

Steve

"Phillip Williams" wrote:
At which stage of the page's lifecycle are you adding your form? Dynamically
added controls need to be added during the Page.Init stage to maintian their
ViewState upon postback.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Steve Bugden" wrote:
Hello,

I am trying to create a form dynamically. A very simple form with a textbox,
requiredvalidator and button.

Everything works fine on IE, but no server side validation occurs which
means the requiredfieldvalidator is ignored when using Netscape.

The code logic is:

'Declare a an html form i.e
Dim objForm As New HtmlForm
objForm.Attributes.Add("RunAt", "Server")

Create a table, tablerow and tablecell

Add a textbox and requirefieldvalidator to a cell
Add the cell to the row
Add the row to the table
Add a button to the table
Add the table to the form
Add the form to a placeholder control on the web page

Is there something I am missing? I tried adding the requiredfieldvalidator
control to the validators collection of the page, ie
Me.Validators.Add(validatorcontrol)
as described in http://forums.asp.net/577243/ShowPost.aspx but that makes no
difference.

I have switched off clientside validation and get the same result in IE.

Is there something simple I am missing or do I really need to take a serious
look at creating user controls in asp.net?

Best Regards,

Steve Bugden

Feb 28 '06 #4
You are welcome, Steve.
--
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Steve Bugden" wrote:
Hi Phillip,

Sorry for such a stupid question, I just cleared the placeholder in the
page_load event if the form is valid.

Thanks once again for you help,

Steve Bugden.

"Steve Bugden" wrote:
Hi Phillip,

Thanks for the reply.

I moved the dynamically added controls from teh page_load event to the
Page_Init event and it now works fine. ie the requiredfieldvvalidator kicks
in if a required field is missing.

But I would also like to display a simple user message (rather than the
form), if the form is valid. On the postback, in the Page_Init event after
calling Me.Page.Validate, Me.Page.IsValid is set true, (Although this works
correctly in the page_load event)

How can I stop the form displaying if the it is valid?

Best Regards,

Steve

"Phillip Williams" wrote:
At which stage of the page's lifecycle are you adding your form? Dynamically
added controls need to be added during the Page.Init stage to maintian their
ViewState upon postback.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Steve Bugden" wrote:

> Hello,
>
> I am trying to create a form dynamically. A very simple form with a textbox,
> requiredvalidator and button.
>
> Everything works fine on IE, but no server side validation occurs which
> means the requiredfieldvalidator is ignored when using Netscape.
>
> The code logic is:
>
> 'Declare a an html form i.e
> Dim objForm As New HtmlForm
> objForm.Attributes.Add("RunAt", "Server")
>
> Create a table, tablerow and tablecell
>
> Add a textbox and requirefieldvalidator to a cell
> Add the cell to the row
> Add the row to the table
> Add a button to the table
> Add the table to the form
> Add the form to a placeholder control on the web page
>
> Is there something I am missing? I tried adding the requiredfieldvalidator
> control to the validators collection of the page, ie
> Me.Validators.Add(validatorcontrol)
> as described in http://forums.asp.net/577243/ShowPost.aspx but that makes no
> difference.
>
> I have switched off clientside validation and get the same result in IE.
>
> Is there something simple I am missing or do I really need to take a serious
> look at creating user controls in asp.net?
>
> Best Regards,
>
> Steve Bugden

Feb 28 '06 #5
Which version of the framework are you using?

Bye
Andrea

Feb 28 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Venus | last post: by
reply views Thread by Venus | last post: by
4 posts views Thread by Brian Shannon | last post: by
7 posts views Thread by Abraham Luna | last post: by
4 posts views Thread by easoftware | last post: by
27 posts views Thread by Chris | last post: by
1 post views Thread by gau.tai | last post: by
19 posts views Thread by zacks | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.