HtmlSelect和RequiredFieldValidator [英] HtmlSelect and RequiredFieldValidator

查看:84
本文介绍了HtmlSelect和RequiredFieldValidator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常奇怪的问题和HtmlSelect服务器控件

(列表框)和一个RequiredFieldValidator,我试图确保

那个人列表框中有项目。


HtmlSelect的填充方式是通过客户端

javascript和另一个aspx页面的组合(由javascript)。


无论如何,在填充

HtmlSelect方面,一切似乎都运行得很好。但是,当我回发表单时,RequiredFieldValidator

总是认为HtmlSelect中没有任何内容并且验证失败

(我只使用服务器端验证,办法)。我有

ControlToValidate和所有这些东西正确连接。是否有一些

技巧为HtmlSelect控件设置RequiredFieldValidator?我没有设置一些

属性?我怀疑有一些我错过的小设置

,但是我花了太多时间来保持

挣扎。

感谢任何帮助,

谢谢

I''m having a really strange problem with and HtmlSelect server control
(listbox) and a RequiredFieldValidator that I am trying to use to make sure
that someone has items in the listbox.

The way that the HtmlSelect is populated is via a combination of client-side
javascript and another aspx page (launched by the javascript).

Anyway, everything seems to work just fine in terms of populating the
HtmlSelect. However, when I postback the form, the RequiredFieldValidator
always thinks that there is nothing in the HtmlSelect and fails validation
(I am only using server-side validation, by the way). I have the
ControlToValidate and all those things hooked up properly. Is there some
trick to setting the RequiredFieldValidator for an HtmlSelect control? Some
property that I am not setting?? I suspect that there is some small setting
that I am missing, but I have spent way too much time on this to keep
struggling.

Any help is appreciated,
Thanks

推荐答案

我不希望服务器端验证处理客户端添加的项目。


看看: http://openmymind.net/FAQ.aspx?documentId=1


但快速回答是当你添加物品时javascript,他们不是
添加到viewstate这意味着他们不会被重新创建

回发...解释为什么你的htmlselect是空的...


Karl

-

我的ASP.Net教程
http://www.openmymind.net/ - 新增和改进(是的,弹出窗口很烦人)
http://www.openmymind.net/faq.aspx - 非官方新闻组常见问题解答(更多内容

来了!)

" BK" <无***** @ hotmail.com>在消息中写道

news:uM ************* @ tk2msftngp13.phx.gbl ...
I wouldn''t expect server-side validation to work on client-side added items.

Take a look at: http://openmymind.net/FAQ.aspx?documentId=1

but the quick answer is that when you add items in javascript, they aren''t
added to the viewstate which means they won''t be recreated on
postback...explains why your htmlselect is empty...

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"BK" <no*****@hotmail.com> wrote in message
news:uM*************@tk2msftngp13.phx.gbl...
我有一个和HtmlSelect服务器控件(listbox)以及我试图使用的RequiredFieldValidator确实奇怪的问题
确定有人在列表框中有项目。
HtmlSelect的填充方式是通过
客户端
javascript和另一个aspx页面(由javascript启动)的组合。

无论如何,一切似乎都有效在填充
HtmlSelect方面很好。但是,当我回发表单时,RequiredFieldValidator总是认为HtmlSelect中没有任何内容并且验证失败
(顺便说一下,我只使用服务器端验证)。我有
ControlToValidate和所有这些东西正确连接。是否有一些为HtmlSelect控件设置RequiredFieldValidator的技巧?
我没有设置的一些
属性?我怀疑有一些小的
设置我错过了,但是我花了太多时间来保持这一点。

任何帮助都是赞赏,
谢谢
I''m having a really strange problem with and HtmlSelect server control
(listbox) and a RequiredFieldValidator that I am trying to use to make
sure
that someone has items in the listbox.

The way that the HtmlSelect is populated is via a combination of
client-side
javascript and another aspx page (launched by the javascript).

Anyway, everything seems to work just fine in terms of populating the
HtmlSelect. However, when I postback the form, the RequiredFieldValidator
always thinks that there is nothing in the HtmlSelect and fails validation
(I am only using server-side validation, by the way). I have the
ControlToValidate and all those things hooked up properly. Is there some
trick to setting the RequiredFieldValidator for an HtmlSelect control?
Some
property that I am not setting?? I suspect that there is some small
setting
that I am missing, but I have spent way too much time on this to keep
struggling.

Any help is appreciated,
Thanks



卡尔解释说不要指望HtmlSelect验证


***通过开发人员指南 http://www.developersdex.com 发送** *
As Karl explained don''t expect HtmlSelect to validate

*** Sent via Developersdex http://www.developersdex.com ***


好的,这对我来说很有意义。但是,我所拥有的所有文件

read表明RequiredFieldValidator与HtmlSelect服务器

控件一起使用。我想你说的是需要添加的项目

服务器端才能使用?


此外,如果是这种情况,那么有没有办法在描述的场景中将它们添加到viewstate

,还是我必须做一些复杂的

CustomValidation我检查Request集合?基于下面的常见问题解答

,我假设转换为网页控件也无法解决

问题 - 这似乎是客户端与服务器端问题对于验证的工作方式,请考虑

.


Brian


" Karl Seguin" < karl REMOVE @ REMOVE openmymind REMOVEMETOO。 ANDME net>

在消息新闻中写道:uP ************** @ TK2MSFTNGP14.phx.gbl ...
OK, this sort of makes sense to me. But, all the documentation that I have
read says that the RequiredFieldValidator works with an HtmlSelect server
control. I guess what you are saying is that the items need to be added
server-side for this to work?

Also, if this is the case, then is there a way to add them to the viewstate
in the described scenario or will I have to do some kind of convoluted
CustomValidation where I check the Request collection? Based upon the FAQ
below, I am assuming that converting to web controls wouldn''t solve the
problem either - this seems to be a client vs server side issue with regard
to how the validation works.

Brian

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uP**************@TK2MSFTNGP14.phx.gbl...
我不知道不希望服务器端验证在客户端添加
项目。
看看: http://openmymind.net/FAQ.aspx?documentId=1

但快速回答是当你添加项目时javascript,它们没有被添加到viewstate中,这意味着它们不会在
回发中重新创建...解释为什么你的htmlselect是空的......

Karl

-
我的ASP.Net教程
http://www.openmymind.net/ - 新增和改进(是的,弹出窗口令人讨厌)
http://www.openmymind.net/faq.aspx - 非官方新闻组常见问题解答(更多内容来了!)

" BK" <无***** @ hotmail.com>在消息中写道
新闻:uM ************* @ tk2msftngp13.phx.gbl ...
I wouldn''t expect server-side validation to work on client-side added items.
Take a look at: http://openmymind.net/FAQ.aspx?documentId=1

but the quick answer is that when you add items in javascript, they aren''t
added to the viewstate which means they won''t be recreated on
postback...explains why your htmlselect is empty...

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"BK" <no*****@hotmail.com> wrote in message
news:uM*************@tk2msftngp13.phx.gbl...
我有一个非常奇怪的问题和HtmlSelect服务器控件
(列表框)和一个RequiredFieldValidator,我试图使用
确定有人在列表框中有项目。

的方式HtmlSelect是通过组合客户端
javascript和另一个aspx页面(由javascript启动)填充的。

无论如何,一切似乎工作得很好填充HtmlSelect。但是,当我回发表单时,
RequiredFieldValidator始终认为HtmlSelect中没有任何内容并且无法通过
验证(顺便说一下,我只使用服务器端验证)。我有
ControlToValidate和所有这些东西正确连接。是否有一些为HtmlSelect控件设置RequiredFieldValidator的技巧?
我没有设置的一些
属性?我怀疑有一些小的
设置我错过了,但是我花了太多时间来保持这一点。

任何帮助都是赞赏,
谢谢
I''m having a really strange problem with and HtmlSelect server control
(listbox) and a RequiredFieldValidator that I am trying to use to make
sure
that someone has items in the listbox.

The way that the HtmlSelect is populated is via a combination of
client-side
javascript and another aspx page (launched by the javascript).

Anyway, everything seems to work just fine in terms of populating the
HtmlSelect. However, when I postback the form, the RequiredFieldValidator always thinks that there is nothing in the HtmlSelect and fails validation (I am only using server-side validation, by the way). I have the
ControlToValidate and all those things hooked up properly. Is there some
trick to setting the RequiredFieldValidator for an HtmlSelect control?
Some
property that I am not setting?? I suspect that there is some small
setting
that I am missing, but I have spent way too much time on this to keep
struggling.

Any help is appreciated,
Thanks




这篇关于HtmlSelect和RequiredFieldValidator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆