English 中文(简体)
防止产生某些Validator的蚊帐。
原标题:Prevent asp.net generating someValidator.display = "Dynamic";
  • 时间:2010-01-11 13:51:57
  •  标签:
  • asp.net

我的“p.net”网页动态显示207个问题(我可以控制这个问题)。 每个问题都有10个有效者。 伙伴关系在提供网页时,为每个有效者设立以下三条线路:

var qsnQuestionSet_adult_qcQuestion_1_vldMaxAnswersValidator = document.all ? document.all["qsnQuestionSet_adult_qcQuestion_1_vldMaxAnswersValidator"] : document.getElementById("qsnQuestionSet_adult_qcQuestion_1_vldMaxAnswersValidator");
qsnQuestionSet_adult_qcQuestion_1_vldMaxAnswersValidator.display = "Dynamic";
qsnQuestionSet_adult_qcQuestion_1_vldMaxAnswersValidator.evaluationfunction = "CustomValidatorEvaluateIsValid";

通过这三条线路,你只能想象4*10*207是相当可观的。 我怎么能够把所有有效的机构都视为动态的,把评价功能设定为同样的价值,而不给我带来一线。

最佳回答

This code is generated automatically by ASP.NET when the EnableClientScript option is set to true. As far as I m aware the only way to get rid of it would be to set this to false however the obvious drawback is the validation will only happen on the server side during a postback.
To get around this you could tie the custom javascript validation function to the related control event such as a textbox onBlur event but without knowing more detail about what values you are trying to validate it is difficult to speculate further as to whether this could be a solution.

问题回答

基地Validator &的AddAttributes ToRender()方法向客户提供这一java语;该系统的定制器级。 Web.UI. WebControls namespace. http://www.red-gate.com/products/reflector/“rel=“nofollow noreferer”>。

Protected Overrides Sub AddAttributesToRender(ByVal writer As HtmlTextWriter)
  ...
  If (enumValue <> ValidatorDisplay.Static) Then
    Me.AddExpandoAttribute(writer2, clientID, "display", PropertyConverter.EnumToString(GetType(ValidatorDisplay), enumValue), False)
  End If
  ...
  MyBase.AddExpandoAttribute(writer2, clientID, "evaluationfunction", "CustomValidatorEvaluateIsValid", False)
End Sub

You could write your own class to replace CustomValidator and change the way that it renders. But, in this case I think it would be better to write your own javascript to handle validation and not use the validator controls.

P.S. 如果你对超文本的大小表示担忧,你应做的第一项工作是使国际电子数据处理服务器能够压缩。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签