Validators in composite control firing prematurely

B

Brad

I have a custom composite control with some text boxes, which have
validators (requiredfieldvalidators + regularexpression validators). The
problem is the validators are working to well and seem to be firing even on
a postback which is set to not cause validation.....and the postback
correctly does not cause validation for any of the other input validators on
the aspx page.
I'm using the CreateChildControls method to set the properties of the
composite items and then write them out in Render, interspersed with some
table formatting.

If this makes sense and you have some thoughts one what I might look into to
correct this I'd appreciate some feedback.

Brad

This in .Net 1.1
 
S

Steven Cheng[MSFT]

Hi Brad,

Welcome to ASPNET control newsgroup.
from your description, you're developing a custom composite web control and
there're some entry fields and validation controls in the composte control.
Currently you found that the validator controls will always validate the
input in all the postback events on the page, so you're wondering any means
to make them invoking validation only when the postback is raised by the
button in your custom control?

If anything I misunderstand, please feel free to let me know. As for the
ASP.NET's page validation model in 1.X , all the validation controls on the
page are in the same scope , so any submit button's postback on the page
will cause the validation take place (as long as that button's set to
causeValidation=true....). In ASP.NET 2.0, we can resolve this problems
through defining ValidationGroup for our custom control's validators....

Currently what I can got to workaround the problem in 1.1 may be creating a
custom Validator control to do the validation in our custom composite
control. We can put our code logic in the overrided validation function to
determine whether to do the validtion or not (only when the post back in
invoked by the button in our composite control .....). This checking can
be done through check the Page's Request.Forms collection to see whether
the submit button's UniqueID is in it...

If you have any other consideration or concerns, please feel free to post
here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Brad" <[email protected]>
| Subject: Validators in composite control firing prematurely
| Date: Mon, 28 Nov 2005 17:43:10 -0800
| Lines: 18
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: xllc.ris.lane.or.us 199.79.32.18
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:31369
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| I have a custom composite control with some text boxes, which have
| validators (requiredfieldvalidators + regularexpression validators). The
| problem is the validators are working to well and seem to be firing even
on
| a postback which is set to not cause validation.....and the postback
| correctly does not cause validation for any of the other input validators
on
| the aspx page.
| I'm using the CreateChildControls method to set the properties of the
| composite items and then write them out in Render, interspersed with some
| table formatting.
|
| If this makes sense and you have some thoughts one what I might look into
to
| correct this I'd appreciate some feedback.
|
| Brad
|
| This in .Net 1.1
|
|
|
 
S

Steven Cheng[MSFT]

Hey Brad,

Have you got any further idea on this? I've just made some further test
and seems we can do some certain trick in our composite control's code. My
current approach is just set the validator's Enabled property to false in
CreateChildControl....

Then, we override our Custom Control's OnLoad method , there when postback,
the validation hasn't take place.... , we can check the Page.Request.Form
collection to see whether the postback is caused by the button in our
composite control. If so, set validator's Enabed to true and manually call
validator's Validate() function, else, set to false....

Also, this approach need to disable clientside validation (since the
enabled state we set in Onload will be persisted take effect at clientside
). If you also need the clientside validation occurs only for our
composte control's sub buttons, we may have to register some custom
clientscript which manually call the validator's clientside validation
function. I think it is also possible, just refer to the following msdn
article which describe the asp.net 1.x validation control's clientside
behavior in detail:

#ASP.NET Validation in Depth
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspplusvalid.asp

Here is the my test control's code:
================================
namespace DTControlLib
{
[DefaultProperty("Text"),
ToolboxData("<{0}:ValidateCompositeControl
runat=server></{0}:ValidateCompositeControl>")]
public class ValidateCompositeControl :
System.Web.UI.WebControls.WebControl, INamingContainer
{
private string text;
private TextBox _txt;
private RequiredFieldValidator _rfv;
private Button _btn;
private DropDownList _lst;


[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
return text;
}

set
{
text = value;
}
}


protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);

if(Page.IsPostBack)
{
if(Page.Request.Form[_btn.UniqueID] != null)
{

_rfv.Enabled = true;
_rfv.Validate();
}
else
{
_rfv.Enabled = false;
}
}

}


protected override void CreateChildControls()
{
Controls.Clear();

Table tb = new Table();
tb.ID = "tbContainer";
tb.BorderWidth= 1;
tb.CellPadding = tb.CellSpacing = 0;

Controls.Add(tb);


TableRow tr = null;


tr= new TableRow();
tr.Cells.Add(new TableCell());


_txt = new TextBox();
_txt.ID = "txtInput";

_rfv = new RequiredFieldValidator();
_rfv.ID = "rfvInput";
_rfv.ControlToValidate = _txt.ID;
_rfv.EnableClientScript = false;
_rfv.ErrorMessage = "Input value required.....";
_rfv.Enabled = false;

tr.Cells[0].Controls.Add(_txt);
tr.Cells[0].Controls.Add(_rfv);

tb.Rows.Add(tr);


tr= new TableRow();
tr.Cells.Add(new TableCell());


_lst = new DropDownList();
_lst.ID = "lstItems";
_lst.AutoPostBack = true;
_lst.Items.Add("Item1");
_lst.Items.Add("Item2");
_lst.Items.Add("Item3");


tr.Cells[0].Controls.Add(_lst);

tb.Rows.Add(tr);



tr= new TableRow();
tr.Cells.Add(new TableCell());


_btn = new Button();
_btn.ID = "btnSubmit";
_btn.Text = "Submit Input";
_btn.Click += new EventHandler(btn_Click);
_btn.CausesValidation = false;


tr.Cells[0].Controls.Add(_btn);

tb.Rows.Add(tr);

}


private void btn_Click(object sender, EventArgs e)
{

Page.Response.Write("<br>" + sender + " postback.");
}

}
}
==========================

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| X-Tomcat-ID: 223188659
| References: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Tue, 29 Nov 2005 09:15:15 GMT
| Subject: RE: Validators in composite control firing prematurely
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| Lines: 81
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:31372
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Hi Brad,
|
| Welcome to ASPNET control newsgroup.
| from your description, you're developing a custom composite web control
and
| there're some entry fields and validation controls in the composte
control.
| Currently you found that the validator controls will always validate the
| input in all the postback events on the page, so you're wondering any
means
| to make them invoking validation only when the postback is raised by the
| button in your custom control?
|
| If anything I misunderstand, please feel free to let me know. As for the
| ASP.NET's page validation model in 1.X , all the validation controls on
the
| page are in the same scope , so any submit button's postback on the page
| will cause the validation take place (as long as that button's set to
| causeValidation=true....). In ASP.NET 2.0, we can resolve this
problems
| through defining ValidationGroup for our custom control's validators....
|
| Currently what I can got to workaround the problem in 1.1 may be creating
a
| custom Validator control to do the validation in our custom composite
| control. We can put our code logic in the overrided validation function
to
| determine whether to do the validtion or not (only when the post back in
| invoked by the button in our composite control .....). This checking can
| be done through check the Page's Request.Forms collection to see whether
| the submit button's UniqueID is in it...
|
| If you have any other consideration or concerns, please feel free to post
| here.
|
| Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
| --------------------
| | From: "Brad" <[email protected]>
| | Subject: Validators in composite control firing prematurely
| | Date: Mon, 28 Nov 2005 17:43:10 -0800
| | Lines: 18
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| | Message-ID: <[email protected]>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| | NNTP-Posting-Host: xllc.ris.lane.or.us 199.79.32.18
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.framework.aspnet.webcontrols:31369
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| |
| | I have a custom composite control with some text boxes, which have
| | validators (requiredfieldvalidators + regularexpression validators).
The
| | problem is the validators are working to well and seem to be firing
even
| on
| | a postback which is set to not cause validation.....and the postback
| | correctly does not cause validation for any of the other input
validators
| on
| | the aspx page.
| | I'm using the CreateChildControls method to set the properties of the
| | composite items and then write them out in Render, interspersed with
some
| | table formatting.
| |
| | If this makes sense and you have some thoughts one what I might look
into
| to
| | correct this I'd appreciate some feedback.
| |
| | Brad
| |
| | This in .Net 1.1
| |
| |
| |
|
|
 
B

Brad

Actually the problem was far simpler. My custom control included an
hyperlink using the htmlanchor object. For some reason this was causing the
problem....and replacing it with a hyperlink webcontrol resolved the
problem.

Thank you for your time.

Brad


Hey Brad,

Have you got any further idea on this? I've just made some further test
and seems we can do some certain trick in our composite control's code. My
current approach is just set the validator's Enabled property to false in
CreateChildControl....

Then, we override our Custom Control's OnLoad method , there when postback,
the validation hasn't take place.... , we can check the Page.Request.Form
collection to see whether the postback is caused by the button in our
composite control. If so, set validator's Enabed to true and manually call
validator's Validate() function, else, set to false....

Also, this approach need to disable clientside validation (since the
enabled state we set in Onload will be persisted take effect at clientside
). If you also need the clientside validation occurs only for our
composte control's sub buttons, we may have to register some custom
clientscript which manually call the validator's clientside validation
function. I think it is also possible, just refer to the following msdn
article which describe the asp.net 1.x validation control's clientside
behavior in detail:

#ASP.NET Validation in Depth
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspplusvalid.asp

Here is the my test control's code:
================================
namespace DTControlLib
{
[DefaultProperty("Text"),
ToolboxData("<{0}:ValidateCompositeControl
runat=server></{0}:ValidateCompositeControl>")]
public class ValidateCompositeControl :
System.Web.UI.WebControls.WebControl, INamingContainer
{
private string text;
private TextBox _txt;
private RequiredFieldValidator _rfv;
private Button _btn;
private DropDownList _lst;


[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
return text;
}

set
{
text = value;
}
}


protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);

if(Page.IsPostBack)
{
if(Page.Request.Form[_btn.UniqueID] != null)
{

_rfv.Enabled = true;
_rfv.Validate();
}
else
{
_rfv.Enabled = false;
}
}

}


protected override void CreateChildControls()
{
Controls.Clear();

Table tb = new Table();
tb.ID = "tbContainer";
tb.BorderWidth= 1;
tb.CellPadding = tb.CellSpacing = 0;

Controls.Add(tb);


TableRow tr = null;


tr= new TableRow();
tr.Cells.Add(new TableCell());


_txt = new TextBox();
_txt.ID = "txtInput";

_rfv = new RequiredFieldValidator();
_rfv.ID = "rfvInput";
_rfv.ControlToValidate = _txt.ID;
_rfv.EnableClientScript = false;
_rfv.ErrorMessage = "Input value required.....";
_rfv.Enabled = false;

tr.Cells[0].Controls.Add(_txt);
tr.Cells[0].Controls.Add(_rfv);

tb.Rows.Add(tr);


tr= new TableRow();
tr.Cells.Add(new TableCell());


_lst = new DropDownList();
_lst.ID = "lstItems";
_lst.AutoPostBack = true;
_lst.Items.Add("Item1");
_lst.Items.Add("Item2");
_lst.Items.Add("Item3");


tr.Cells[0].Controls.Add(_lst);

tb.Rows.Add(tr);



tr= new TableRow();
tr.Cells.Add(new TableCell());


_btn = new Button();
_btn.ID = "btnSubmit";
_btn.Text = "Submit Input";
_btn.Click += new EventHandler(btn_Click);
_btn.CausesValidation = false;


tr.Cells[0].Controls.Add(_btn);

tb.Rows.Add(tr);

}


private void btn_Click(object sender, EventArgs e)
{

Page.Response.Write("<br>" + sender + " postback.");
}

}
}
==========================

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| X-Tomcat-ID: 223188659
| References: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Tue, 29 Nov 2005 09:15:15 GMT
| Subject: RE: Validators in composite control firing prematurely
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| Lines: 81
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:31372
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Hi Brad,
|
| Welcome to ASPNET control newsgroup.
| from your description, you're developing a custom composite web control
and
| there're some entry fields and validation controls in the composte
control.
| Currently you found that the validator controls will always validate the
| input in all the postback events on the page, so you're wondering any
means
| to make them invoking validation only when the postback is raised by the
| button in your custom control?
|
| If anything I misunderstand, please feel free to let me know. As for the
| ASP.NET's page validation model in 1.X , all the validation controls on
the
| page are in the same scope , so any submit button's postback on the page
| will cause the validation take place (as long as that button's set to
| causeValidation=true....). In ASP.NET 2.0, we can resolve this
problems
| through defining ValidationGroup for our custom control's validators....
|
| Currently what I can got to workaround the problem in 1.1 may be creating
a
| custom Validator control to do the validation in our custom composite
| control. We can put our code logic in the overrided validation function
to
| determine whether to do the validtion or not (only when the post back in
| invoked by the button in our composite control .....). This checking can
| be done through check the Page's Request.Forms collection to see whether
| the submit button's UniqueID is in it...
|
| If you have any other consideration or concerns, please feel free to post
| here.
|
| Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
| --------------------
| | From: "Brad" <[email protected]>
| | Subject: Validators in composite control firing prematurely
| | Date: Mon, 28 Nov 2005 17:43:10 -0800
| | Lines: 18
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| | Message-ID: <[email protected]>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| | NNTP-Posting-Host: xllc.ris.lane.or.us 199.79.32.18
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.framework.aspnet.webcontrols:31369
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| |
| | I have a custom composite control with some text boxes, which have
| | validators (requiredfieldvalidators + regularexpression validators).
The
| | problem is the validators are working to well and seem to be firing
even
| on
| | a postback which is set to not cause validation.....and the postback
| | correctly does not cause validation for any of the other input
validators
| on
| | the aspx page.
| | I'm using the CreateChildControls method to set the properties of the
| | composite items and then write them out in Render, interspersed with
some
| | table formatting.
| |
| | If this makes sense and you have some thoughts one what I might look
into
| to
| | correct this I'd appreciate some feedback.
| |
| | Brad
| |
| | This in .Net 1.1
| |
| |
| |
|
|
 
S

Steven Cheng[MSFT]

Thanks for the followup Brad,

Glad that you've already got it working. Also, if there're any further
problems or anything else we can help, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| From: "Brad" <[email protected]>
| References: <[email protected]>
<[email protected]>
<IrnaL#[email protected]>
| Subject: Re: Validators in composite control firing prematurely
| Date: Thu, 1 Dec 2005 15:50:13 -0800
| Lines: 295
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: xllc.ris.lane.or.us 199.79.32.18
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:31477
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Actually the problem was far simpler. My custom control included an
| hyperlink using the htmlanchor object. For some reason this was causing
the
| problem....and replacing it with a hyperlink webcontrol resolved the
| problem.
|
| Thank you for your time.
|
| Brad
|
|
| | Hey Brad,
|
| Have you got any further idea on this? I've just made some further test
| and seems we can do some certain trick in our composite control's code. My
| current approach is just set the validator's Enabled property to false in
| CreateChildControl....
|
| Then, we override our Custom Control's OnLoad method , there when
postback,
| the validation hasn't take place.... , we can check the Page.Request.Form
| collection to see whether the postback is caused by the button in our
| composite control. If so, set validator's Enabed to true and manually call
| validator's Validate() function, else, set to false....
|
| Also, this approach need to disable clientside validation (since the
| enabled state we set in Onload will be persisted take effect at
clientside
| ). If you also need the clientside validation occurs only for our
| composte control's sub buttons, we may have to register some custom
| clientscript which manually call the validator's clientside validation
| function. I think it is also possible, just refer to the following msdn
| article which describe the asp.net 1.x validation control's clientside
| behavior in detail:
|
| #ASP.NET Validation in Depth
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
| /aspplusvalid.asp
|
| Here is the my test control's code:
| ================================
| namespace DTControlLib
| {
| [DefaultProperty("Text"),
| ToolboxData("<{0}:ValidateCompositeControl
| runat=server></{0}:ValidateCompositeControl>")]
| public class ValidateCompositeControl :
| System.Web.UI.WebControls.WebControl, INamingContainer
| {
| private string text;
| private TextBox _txt;
| private RequiredFieldValidator _rfv;
| private Button _btn;
| private DropDownList _lst;
|
|
| [Bindable(true),
| Category("Appearance"),
| DefaultValue("")]
| public string Text
| {
| get
| {
| return text;
| }
|
| set
| {
| text = value;
| }
| }
|
|
| protected override void OnLoad(EventArgs e)
| {
| base.OnLoad (e);
|
| if(Page.IsPostBack)
| {
| if(Page.Request.Form[_btn.UniqueID] != null)
| {
|
| _rfv.Enabled = true;
| _rfv.Validate();
| }
| else
| {
| _rfv.Enabled = false;
| }
| }
|
| }
|
|
| protected override void CreateChildControls()
| {
| Controls.Clear();
|
| Table tb = new Table();
| tb.ID = "tbContainer";
| tb.BorderWidth= 1;
| tb.CellPadding = tb.CellSpacing = 0;
|
| Controls.Add(tb);
|
|
| TableRow tr = null;
|
|
| tr= new TableRow();
| tr.Cells.Add(new TableCell());
|
|
| _txt = new TextBox();
| _txt.ID = "txtInput";
|
| _rfv = new RequiredFieldValidator();
| _rfv.ID = "rfvInput";
| _rfv.ControlToValidate = _txt.ID;
| _rfv.EnableClientScript = false;
| _rfv.ErrorMessage = "Input value required.....";
| _rfv.Enabled = false;
|
| tr.Cells[0].Controls.Add(_txt);
| tr.Cells[0].Controls.Add(_rfv);
|
| tb.Rows.Add(tr);
|
|
| tr= new TableRow();
| tr.Cells.Add(new TableCell());
|
|
| _lst = new DropDownList();
| _lst.ID = "lstItems";
| _lst.AutoPostBack = true;
| _lst.Items.Add("Item1");
| _lst.Items.Add("Item2");
| _lst.Items.Add("Item3");
|
|
| tr.Cells[0].Controls.Add(_lst);
|
| tb.Rows.Add(tr);
|
|
|
| tr= new TableRow();
| tr.Cells.Add(new TableCell());
|
|
| _btn = new Button();
| _btn.ID = "btnSubmit";
| _btn.Text = "Submit Input";
| _btn.Click += new EventHandler(btn_Click);
| _btn.CausesValidation = false;
|
|
| tr.Cells[0].Controls.Add(_btn);
|
| tb.Rows.Add(tr);
|
| }
|
|
| private void btn_Click(object sender, EventArgs e)
| {
|
| Page.Response.Write("<br>" + sender + " postback.");
| }
|
| }
| }
| ==========================
|
| Hope helps. Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
| --------------------
| | X-Tomcat-ID: 223188659
| | References: <[email protected]>
| | MIME-Version: 1.0
| | Content-Type: text/plain
| | Content-Transfer-Encoding: 7bit
| | From: (e-mail address removed) (Steven Cheng[MSFT])
| | Organization: Microsoft
| | Date: Tue, 29 Nov 2005 09:15:15 GMT
| | Subject: RE: Validators in composite control firing prematurely
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| | Message-ID: <[email protected]>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| | Lines: 81
| | Path: TK2MSFTNGXA02.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.framework.aspnet.webcontrols:31372
| | NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
| |
| | Hi Brad,
| |
| | Welcome to ASPNET control newsgroup.
| | from your description, you're developing a custom composite web control
| and
| | there're some entry fields and validation controls in the composte
| control.
| | Currently you found that the validator controls will always validate the
| | input in all the postback events on the page, so you're wondering any
| means
| | to make them invoking validation only when the postback is raised by the
| | button in your custom control?
| |
| | If anything I misunderstand, please feel free to let me know. As for
the
| | ASP.NET's page validation model in 1.X , all the validation controls on
| the
| | page are in the same scope , so any submit button's postback on the page
| | will cause the validation take place (as long as that button's set to
| | causeValidation=true....). In ASP.NET 2.0, we can resolve this
| problems
| | through defining ValidationGroup for our custom control's validators....
| |
| | Currently what I can got to workaround the problem in 1.1 may be
creating
| a
| | custom Validator control to do the validation in our custom composite
| | control. We can put our code logic in the overrided validation function
| to
| | determine whether to do the validtion or not (only when the post back in
| | invoked by the button in our composite control .....). This checking
can
| | be done through check the Page's Request.Forms collection to see whether
| | the submit button's UniqueID is in it...
| |
| | If you have any other consideration or concerns, please feel free to
post
| | here.
| |
| | Thanks,
| |
| | Steven Cheng
| | Microsoft Online Support
| |
| | Get Secure! www.microsoft.com/security
| | (This posting is provided "AS IS", with no warranties, and confers no
| | rights.)
| |
| |
| | --------------------
| | | From: "Brad" <[email protected]>
| | | Subject: Validators in composite control firing prematurely
| | | Date: Mon, 28 Nov 2005 17:43:10 -0800
| | | Lines: 18
| | | X-Priority: 3
| | | X-MSMail-Priority: Normal
| | | X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| | | Message-ID: <[email protected]>
| | | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| | | NNTP-Posting-Host: xllc.ris.lane.or.us 199.79.32.18
| | | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
| | | Xref: TK2MSFTNGXA02.phx.gbl
| | microsoft.public.dotnet.framework.aspnet.webcontrols:31369
| | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| | |
| | | I have a custom composite control with some text boxes, which have
| | | validators (requiredfieldvalidators + regularexpression validators).
| The
| | | problem is the validators are working to well and seem to be firing
| even
| | on
| | | a postback which is set to not cause validation.....and the postback
| | | correctly does not cause validation for any of the other input
| validators
| | on
| | | the aspx page.
| | | I'm using the CreateChildControls method to set the properties of the
| | | composite items and then write them out in Render, interspersed with
| some
| | | table formatting.
| | |
| | | If this makes sense and you have some thoughts one what I might look
| into
| | to
| | | correct this I'd appreciate some feedback.
| | |
| | | Brad
| | |
| | | This in .Net 1.1
| | |
| | |
| | |
| |
| |
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top