Vote count:
0
I have problem in displaying regularexpressionvalidator error message below the text box. from current code snippet its putting regularExp error msg in separate span block.Rather I want it to appear inside the span block which has text box.
DetailRowText.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DetailRowText.ascx.cs" Inherits="Web.UI.UserControls.DetailRowText" ClassName="DetailRowText" %>
<div class="admin-row">
<span class="admin-field">
<asp:TextBox ID="txt" runat="server" Width="200" /> <br />
<asp:RequiredFieldValidator ControlToValidate="txt" ID="valRequired" CssClass="admin-required" Display="Dynamic" runat="server" EnableClientScript="false"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ControlToValidate="txt" ID="valRegex" CssClass="admin-required" Display="Dynamic" runat="server" EnableClientScript="false" ValidationExpression="\d+"></asp:RegularExpressionValidator>
</span>
</div>
A.aspx
<asp:PlaceHolder ID="placeHolder" runat="server" />
A.aspx.cs
prop = t.GetProperty("Description");
rowText = (UserControls.DetailRowText)Page.LoadControl("~/UserControls/DetailRowText.ascx");
rowText.ID = prop.Name;
rowText.IsRequired = true;
this.placeHolder.Controls.Add(rowText);
prop = t.GetProperty("code");
rowText =(UserControls.DetailRowText)Page.LoadControl("~/UserControls/DetailRowText.ascx");
rowText.ID = prop.Name;
rowText.IsRequired = false;
this.placeHolder.Controls.Add(rowText);
RegularExpressionValidator rankRegExpVal = new RegularExpressionValidator();
rankRegExpVal.Display = ValidatorDisplay.Static;
rankRegExpVal.ControlToValidate = "txt";
rankRegExpVal.ValidationExpression = "^\\d{1,10}$";
rankRegExpVal.CssClass = "admin-required";
rankRegExpVal.ValidationGroup = "ValGrpAllExisting";
rankRegExpVal.Text = LabelManager.GetString(this.GetLanguageResources(), "code", "code_ErrorMessage", this.UserSession.LanguageString);
rankRegExpVal.ErrorMessage = LabelManager.GetString(this.GetLanguageResources(), "EducationLevel", "code_ErrorMessage", this.UserSession.LanguageString);
rowText.Controls.AddAt(rowText.Controls.Count, rankRegExpVal);
asked 49 secs ago
apply RegExpValidator to user control programmaticaly
Aucun commentaire:
Enregistrer un commentaire