Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










Access Textbox Properties In A Custom Validator?


I want to build a custom validator control that inherits from BaseValidator. It will only be used on textboxes in my asp.net application. How can I get access to the textbox itself (read properties of the textbox) within the custom validator?

Here is what I have in my EvaluateIsValid function:

Dim t As TextBox = CType(Page.FindControl(Me.ControlToValidate), TextBox)
Return t.Text.Length <= t.MaxLength

It can't seem to find the control, so it breaks with a null reference exception. Can I do this another way?


View 1 Replies (Posted: Feb 10 10 at 19:19)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Custom Server Controls :: Access Properties Of Custom WebControl In ASPX Codebehind File?
I have created a custom control that derives from WebControl class. I have defined a property called "ItemCount" in the custom control.

This custom control is created as a separate project and the assembly is added to the main web project (VS 2005 Web Site).

Just to test, I have only one line writer.Write("Hello World!") in the overriden "RenderContents" method in the web control.

Once added to the aspx file, the control renders the text perfectly fine and is declared in the aspx file as

<cc:mycontrol ID="_testControl" runat="server"/>

Now, when I try to access the control "_testControl" in the codebehind, I cannot compile and I get the error as "The name '_testControl' does not exist in current context.

After reading multiple posts, I tried declaring the control in my aspx codebehind as

protected MYControl _testControl;

This comes out to be NULL during run-time. I'm not too familiar with asp.net, but if other controls (e.g. Button, Textbox) are accessible in my codebehind including their properties, should the same logic be not applied to WebControls...they are all the same!

I can create a new instance of the _testControl in the OnInit method, but that defeats the whole purpose. I need to understand what is going on and what is the right way to solve it.

Posted: Jul 19, 2009 05:59 AM

View 1 Replies!   View Related
Web Forms :: Client Side Custom Validator Changing Textbox Values?
I've been working on a task to add a validator to compare the values of two text fields in a ASP.NET 1.1 application.

It uses validators already, so the best approached seemed to involve a CustomValidator. I was inspired by the following example:

[URL]

I got the server side validation working - now I'm trying to add some client-side validation but I'm having a strange issue.

When I click in either of the two text fields, the value of the txtFinalGrade field is overridden to either "true" or "false". I've been having a tough time tracking down the code that's causing this. I tried using the IE Developer Toolbar to trace the script - as well as FireBug in Firefox (though this is an IE-only app) and I'm still trying to figure out what's causing this to happen.

Since I think this is a JavaScript issue, I'm posting that part of my code:

[Code]....

Anyone have ideas of things to try? Anyone have similar issues with textboxes being set to true/false when working with custom validators?

Posted: Mar 19, 2010 08:23 PM

View 3 Replies!   View Related
C# - How To Access Attributes Of Properties In The Model From Strongly Typed Custom HtmlHelper
I have a view that is strongly typed and its model is of type LogOnModel. That LogOnModel has anotated properties like this one:

[Required(ErrorMessage = "Please enter your password")]
[DataType(DataType.Password)]
[Display(Name = "Password", Description = "Your secreet password")]
public string Password { get; set; }

All of them has Display anotation with Display.Descripion property set. I want to create HtmlHelper extension method that will output <span> containg the value of Display.Description property. So for example if I called my extension method DescriptionFor than this code:

<%: Html.DescriptionFor(m => m.Password) %>

should produce following html: <span>Your secreet password</span>

Posted: Mar 18 at 4:27

View 1 Replies!   View Related
C# - Load A User Control In An Ajax WCF Service And Access Custom Properties?
I can load a generic user control just fine in my WCF service doing the following:

UserControl userControl= (UserControl) new Page().LoadControl("~/UserControls/MyControl.ascx");

However i can't seem to find any way to do this

MyControl myControl=(MyControl)userControl;

The reason i need to do this is because my user control has a custom property, person, I need to do the following:

myControl.Person=new Person();

essentially i need to simulate:

<%@ Reference Control="~/UserControls/MyControl.ascx" %>

which normally goes inside asp.net page or master-pages.any way of doing this in an Ajax Enabled WCF Service?

Posted: Apr 4 at 16:23

View 2 Replies!   View Related
How To Create The Custom Validator Instance That Is Linked To The Custom Validator
I created my custom validator in one project, something like that:

[Code]....

he composite control in another project. I added a reference of the custom validator project to the composite control project. I have a textbox in a composite control and I would like to validate this textbox by the composite control I created. But how can I do that? How can I create the custom validator instance that is linked to the custom validator I created?

Posted: Dec 17, 2010 10:47 AM

View 1 Replies!   View Related
Custom Server Controls :: User Control Can't Access The Parent Pages Public Properties
I have built a page that is contained within a master page and it holds 2 user controls

Control A contains a DataList

Control B contains a FormView

I want to pass the selected index from the DataList on Control A to the FormView on Control B so it acts like a master / detail scenario

I created a public property on the page that contains both controls called DataListSelectedIndexA also created a public property for DataListSelectedIndex on the ControlI populate the DataListSelectedIndex property of the Control when the DataList_SelectedIndexChanged event is firedAnd I populate the DataListSelectedIndex property of the page on the OnLoad event of the page.

My problem is that on Control B - (or Control A for that matter) I can't access the public property DataListSelectedIndex

The method I am trying to access this is through - this.Page on the OnLoad even of the Control

Posted: Feb 27, 2008 05:29 PM

View 6 Replies!   View Related
Forms Data Controls :: Access Textbox Text Properties When Gridview Edit Mode
Is it possible to access textbox text properties from codebehindwhen gridview is edit mode? for example I can access label's text properties on gridview row databound event.

[Code]....

So I do not like use Text='<%#Eval("ColumnName")%' this method. I want to manage textbox text properties dynamcily codebehind when click the edit button on gridview. When I clik the edit button these code blocks runs

[Code]....

but rowdatabound event fires again and couldn't find label control. Itlooks for textbox control to bind data but I can not manage this step.

Posted: Jun 16, 2010 12:48 PM

View 1 Replies!   View Related
Does A Custom Validator Have To Be Used With The Validator Callout Extender
I have a validator callout extender that works, it shows the callout box. But, it does a postback. It didn't do a post back the first time I clicked the button but it did for subsequent times. I read on the AJAX site that a custom validator must be used with this for it to work. I'm currently using this with a required field and regular expression validator. It works, the callout appears, but it doesn't work every time with out the post back.I posted this to see if there is a way to get this to work with a required field and regular expression validator, with out using a custom validator. I'm using the newest release of the toolkit, so I thought the documentation may be old, since the callout is appearing.

Posted: Jul 06, 2010 11:01 PM

View 8 Replies!   View Related
Custom Server Controls :: Custom Validator Client-side Validation Cannot Work?
I've been trying to get a custom validator component working that ensures at least one checkbox from a checkboxlist has been checked. I've been used some code I found on dotnetjunkies.com but the client-side validation didn't work. I've been attempting to modify it to get the client-side javascript validation to work with no luck. Basically, I compile the below code into a DLL and add it to my bin folder.

[Code]....

Posted: Jan 13, 2010 11:11 PM

View 2 Replies!   View Related
Custom Server Controls :: Custom Required Field Validator?
I have a custom TextBox and a Custom RequiredFieldValidator. The custom RequiredFieldValidator inherit from RequiredFieldValidator. In the custom TextBox I have a Boolean property called "Required". So if this property is set from the MarkUp I will create an instance of the CustomRequiredFieldValidator in the custom TextBox class. Every thing is working fine except that I am unable to figureout where and how to check the IsValid property of custom RequiredFieldValidator.

Also I am unable to figure out that why protected override bool EvaluateIsValid() is not executing.Please note that I have set all the required properties in the constructor of custom RequiredFieldValidator calss as following

[Code]....

I also placed an Asp Button with CauseValidation="true"; but still the page post back is not occuring. Also the click event of the Button is not executing. What I understand that all this validation is happening on the client side.

my objective is to execute some Business Logic based on either the user has entered value in the custom Textbox or not.

Posted: Sep 25, 2009 02:52 AM

View 4 Replies!   View Related
Custom Server Controls :: Binding Properties Of A Custom Control In A ListView?
I have a custom control derived from CompositeControl that I'm using in the EditItemTemplate and InsertItemTemplate of a ListView. The ListView's data source is an ObjectDataSource.

I use <%#Bind('fieldname') %> to bind the properties of my custom control. I have found that the data will be displayed in my custom control, but when I try to update or insert, the data is not retrieved. I checked the onitemupdating event and saw that NewValues.Count was zero.

Does my custom control need to implement somthing special in order to return its data?

Posted: Jul 06, 2009 08:06 PM

View 4 Replies!   View Related
Custom Server Controls :: Custom Control And Properties Window?
I have made a composite control that has 1 Label Control ,1 TextBox ,1 button and 1 Panel Control. Below is my code:

namespace ServerControl1
{

[
AspNetHostingPermission(SecurityAction.Demand,[code]....

The above code compiles without any error. Also I can drag and drop this control from the Toolbox of my Project on my web form. However I am unable the change the value of my fromLabel control.It allows me to change the value in the properties window.But when I run the form it always shows me its default value which is "From". I want it to be flexible so that any one can change the value in the properties window.

Posted: Jun 01, 2010 12:37 PM

View 3 Replies!   View Related
Custom Server Controls :: Why Custom Gridview Control Not Render HTML Properties Under Properly In Visual Studio 2005
Why custom Gridview control not render html properlies under <Columns> properly in Visual Studio 2005?

For example:

[code]....

Posted: Mar 05, 2010 01:50 PM

View 1 Replies!   View Related
Custom Server Controls :: Custom Control's Constructor / User To Set Thatvariable In The Properties Window After They Drag The Control Onto A Form?
I have a custom control which inherit from the Table class and in the constructor, it takes aan integer as an argument. There is no empty constructor.

Is there a way for the user to set thatvariable in the properties window after they drag the control onto a form.

I know some .NET controls, you can set the source for the parameter to different things like another control's property, QueryString using just the properties window.

Right now, I have to create the control dynamically. I read the query string and then created the object.

Posted: Mar 04, 2010 03:56 PM

View 1 Replies!   View Related
Web Forms :: Best Example For Custom Validator
best example for custom validatorhow can we use..i know that but iam not getting it clearly

Posted: Dec 18, 2009 09:38 AM

View 2 Replies!   View Related
Set Width Of Custom Validator
Does anybody know of a way to set the width of a custom validtor so that the error message text will wrap if it exceeds the specified width? I have a user control that contains a custom validator which the containing page can set the error message on based on specific validation results. he user control sits within a table cell in a page. If the message is very long it simply prints the entire message on a single line ignoring any column widths that are set. I have tried setting the width property on the custom validator itself to no avail.

Posted: Feb 11 10 at 22:53

View 2 Replies!   View Related
MVC :: How And When Custom Model Validator Is Used
I am trying to understand a little more about implementing a custom model validator. I have implemented a custom model validator (derived from DataAnnotationsModelValidator<T>) for my custom validation attribute in order to dovalidation on the client side as well. There is not muchdocumented about DataAnnotationsModelValidator. Besides, implementing client-side validation when is it a good idea or needed to implement a custom model validator for a custom attribute?

A separate question - in trying to understand how and when a custom model validator is used by the framework I noticed that my custom validator is always created with the context (2nd parameter in DataAnnotationsModelValidator<T>'s constructor) being a ViewContext, although it is declared as ControllerContext. Will a validatorever be created with something else than a ViewContext, and if so, when?

Posted: Apr 29, 2010 07:56 PM

View 2 Replies!   View Related
Custom Validator Not Validating Correctly?
In the following code I have a dropdownlist and text box, what I'm trying to achieve is when an item from the dropdownlist is selected it needs to make sure the textbox is not null before page IsValid, if not Page is not valid, what I'm getting is Page is valid is textbox is null and not valid is textbox if populated. I'm new to this and cannot figure out why this is happening

<%@PageLanguage="C#"%>
<html>
<head>
</head>
<body>
<formid="Form1"runat="server">
<p>
Outcome:
<asp:DropDownListID="editStatusTextBox"runat="server"
CausesValidation="True">
<asp:ListItemSelected="true"Value="CallAttempt1"Text="CallAttempt1"/>
<asp:ListItemValue="CallAttempt2"Text="CallAttempt2"/>
<asp:ListItemValue="Contacted-Interested"Text="Contacted-Interested"/>
<asp:ListItemValue="Contacted-NotInterested"Text="Contacted-Notinterested"/>
<asp:ListItemValue="CallbackRequired"Text="CallbackRequired"/>
<asp:ListItemValue="NotinBusiness"Text="NotinBusiness"/>
<asp:ListItemValue="Numbernotinuse"Text="Numbernotinuse"/>
<asp:ListItemValue="Usingalternativeproduct"Text="Usingalternativeproduct"/>
<asp:ListItemValue="Nurture"Text="Nurture"/>
</asp:DropDownList>
Date:
<asp:TextBoxid="editCallBack"
runat="server"></asp:TextBox>
<scriptrunat="server">
voidButton1_Click(Objectsender,EventArgse)
{
if(Page.IsValid)
{
Label1.Text="PageisValid";
}
else
{
Label1.Text="PageNotValid";
}
}
voidValidateNumber(objectsource,ServerValidateEventArgsargs)
{
try
{
if((Eval(editCallBack.Text)==null)&&this.editStatusTextBox.Text=="CallAttempt1")
{
args.IsValid=false;
}
elseif((Eval(editCallBack.Text)==null)&&this.editStatusTextBox.Text=="CallAttempt2")
{
args.IsValid=false;
}
}
catch(Exceptionex)
{
args.IsValid=false;
}
}
</script>
<asp:RequiredFieldValidatorID="RequiredFieldValidator1"runat="server"
ControlToValidate="editCallBack"ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:CustomValidatorid="CustomValidator1"
runat="server"ControlToValidate="editCallBack"
ErrorMessage="YoumustenteraDate"
OnServerValidate="ValidateNumber"></asp:CustomValidator>
</p>
<p>
<asp:Buttonid="Button1"onclick="Button1_Click"
runat="server"Text="Button"></asp:Button>
</p>
<p>
<asp:Labelid="Label1"runat="server"></asp:Label>
</p>
</form>
</body>
</html>

Posted: Mar 16 09

View 2 Replies!   View Related
Custom Validator Not To Trigger On The First Button?
I have two buttons on my page, the first page is View Button and the second is Update Button. View button display's member's personal profile. If I click on the view button, my custom validator automatically trigger, meaning, it automatically displays the error message. Whereas, the custom validator must trigger if I click on the Update button. How am be able to deal with this kind of problem.

Posted: Feb 10, 2010, 00:11

View 6 Replies!   View Related
Web Forms :: Custom Validator Is Not Getting Called?
here is the code "when i select a value from calender customvalidator is not called . . "

[Code]....

Posted: Jan 20, 2011 10:51 AM

View 7 Replies!   View Related
Web Forms :: Calling A Custom Validator
I have a custom validator, which I have set a property for, and I can access this validator from my MVC controller method. However, when I run the code, I am not seeing the error message on the page. My code in the controller method looks like this:

If (!bool)
{
this.view.customValidator.IsValid = false;
this.view.customValidator.Visible = true;
}

Posted: May 12, 2010 08:40 PM

View 2 Replies!   View Related
Web Forms :: Error While Using Custom Validator?
I am using Customvalidator control . I am giving client side validation function in it. On running it is giving error as: ValidationStream is not defined.

Following is the code:

<asp:CustomValidator ID="CustomValidator6" runat="server" ClientValidationFunction="validateDriveDate"

Posted: May 06, 2010 06:21 AM

View 2 Replies!   View Related
Determine Which Custom Validator Will Fire First?
I have two custom validators that are in the same validation group. This validation group is launched by one button. My question is, in what order will the custom validators fire in? It appears that the validator that is placed earlier in the aspx page fires first, but I don't want to rely solely on this.

Posted: Feb 10 10 at 1:11

View 2 Replies!   View Related
Web Forms :: Custom Validator Is Not Working In Ie6?
<asp:TextBox ID="txtMobile" runat="server" MaxLength="11"></asp:TextBox>
<ajaxToolkit:FilteredTextBoxExtender ID="fteMobile" runat="server" TargetControlID="txtMobile"
FilterType="Numbers" />

[code]...

Posted: Feb 09, 2011 01:00 PM

View 2 Replies!   View Related
C# - How To GetProfile By Custom Properties
<profile enabled="true" automaticSaveEnabled="false">
<properties>
<add name="InvitationCode" type="String"/>
</properties>
</profile>

How to get profiles with InvitationCode="foo"? Also can i make property unique?

Posted: Mar 9 at 19:58

View 1 Replies!   View Related
Custom Validator For MaxLength Property Of Textarea
I have quite a few text area's on my page and am wanting to limit the number of characters for each one. However each one should be able to have its own maxlength (i.e. one could be 20 characters and the other could be 100 characters). My validation on the page is all done using custom validation as the built in validation of .NET is not extensible enough for me to display my validation errors how I want to display them. So this is what im wanting to do:

Make a custom validatorPass a MaxLength value from the custom validator into the javascript function, this value must also be accessible from the code behindI can then run client side and server side validation on each textbox control. The problem I am having is passing a MaxLength value to client side script and to server side. Is there a property on custom validators which I can use to pass values around? For instance in Javascript I would want the value of the MaxLength and also the id of the Div which will show the characters remaining, and server side I would need to know the MaxLength. I have done lots of research on this and cannot seem to find an answer.

Posted: May 16, 2010 12:42 PM

View 8 Replies!   View Related
Web Forms :: Custom Validator Text Cannot Disappear
I have a formwith textboxfor name and two dropdownlist for month and years. Textbox has Requiredfieldvalidator and the dropdowns has got ustomvalidator.Initially when i dont enter anything in the text box and leave the dropdownswith default"MM" for month and "YYYY" for year i geterror messagein the validation summary at top and asterisk next to the textbox and dropdowns.Once i enter some text in the textbox andfocus is away from textbox the asterisk disappears but even though i hav selected a valid month and year the asterisk next to the dropdowns is not disappearing.Same problem with the radio buttons.

Posted: Aug 10, 2010 11:19 AM

View 5 Replies!   View Related
Web Forms :: How To Write Custom Validator For DropDownlist
In my page i have DropDownlist.I want to write Custom validator.How to write?

Posted: Jan 25, 2011 05:51 AM

View 3 Replies!   View Related
Checkbox Custom Validator With ValidationSummary Not Working?
I have the following validation which is working fine for the rest of my fields, but trying to get a custom validator to work as part of the validation summary for a checkbox but no joy.

This is what I have at the moment

<script language="javascript" type="text/javascript">
function ValidateTandCs(source, args)
{
args.IsValid = document.getElementById('<%= optIn.ClientID %>').checked;
}
</script>
<asp:ValidationSummary CssClass="highlight"
id="ValidationSummary1"
HeaderText="<p>Please amend these errors below to continue with your
application.</p>" Runat="server" />
<asp:CheckBox id="optIn" runat="server"></asp:CheckBox> I agree to the terms and
conditions of this site and I wish to Opt In for registration.
<asp:CustomValidator ID="valTandCs" ClientValidationFunction="ValidateTandCs"
ValidationGroup="ValidationSummary1" runat="server"
ErrorMessage="Please accept Terms and Conditions before submitting.">
</asp:CustomValidator>

But when I click submit I only see the error messages for my other fields and nothing for this checkbox..

Posted: Jan 25 at 10:51

View 1 Replies!   View Related
Comparing Two Date Format Using Custom Validator
How to compare tow date in format using custom validator and else. I have java script function like as. I want to call this function by using custom validator as

< </ asp:CustomValidator id="CustomValidator2" runat="server" ControlToValidate = "tbMyDate1"
EnableClientScript="True" Display="Static" ClientValidationFunction="Compare" SetFocusOnError="True" >asp:CustomValidator>
function { document.getElementById( Compare()"lblrefdate").innerText="";var m_names = new Array(
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec");
var { { dispMM=i+1; } }
dispdate=document.getElementById("tbMyDate");var
dispDD=dispdate .value.split("-")[0];var s1=dispdate.value.split("-")[1];var
dispMM;var i=0;for(i=0;i<=m_names .length ;i++)if(m_names [i]==s1) var { {
refMM=j+1; } } dispYY=dispdate .value.split("-")[2];var
refdate=document.getElementById("tbMyDate1");var refDD=refdate.value.split("-")[0];var
s2=refdate.value.split("-")[1];var refMM;var
j=0;for(j=0;j<m_names .length ;j++)if(m_names[j]==s2)var
refYY=refdate.value.split("-")[2]; if {
document.getElementById(
} (isNaN (refYY))"lblrefdate").innerText=""; else { { { { {
document.getElementById(
} if(refYY<=dispYY)if(refMM <=dispMM )if(refMM==dispMM)if(refDD <=dispDD )"lblrefdate").innerText="";else { document.getElementById(
} } } "lblrefdate").innerText="Ref Date can Not Be Grater then Disp Date";else {
document.getElementById( } }
"lblrefdate").innerText="Ref Date can Not Be Grater then Disp Date";else
document.getElementById( { } } }
"lblrefdate").innerText="Ref Date can Not Be Grater then Disp Date";

Posted: Dec 14, 2010 09:41 AM

View 2 Replies!   View Related
C# - Custom Validator Firing But It Does Not Update The ValidationSummary
I am working on a custom form field validator, it seems like the custom validator is working by not allowing it to continue to the next page, but it doesn't update the Validation Summary nor does it display the asterisk and the labels that i've made visable. I also have other validators like RequiredFieldValidator on the same field. My ValidationGroup is set, as is the Text and IsValid. I even wrote and set a dummy client side validation method in javascript as some workarounds suggests.

here is the validation summary code in asp.net

[Code]....

Posted: Nov 29 10 at 21:54

View 1 Replies!   View Related
Custom Validator Dynamic ServerValidate Using Reflection
I have a UserControl which contains a TextBox and a CustomValidator. I would like to set the CustomValidator.ServerValidate to a method in the page that contains the UserControl I found this code which will allow me to dynamically set the custom validators validation function: cusvCustom.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(MethodName);

The problem is that a string value won't work there. It needs to be a reference to the method. Is it possible to use reflection (or some other method) to get a valid reference to the parent controls method using only the string name of it? The reason I want to use the string value of the method name is so I can place the control on the page thusly: <uc1:TextBoxField ID="tbUserName" runat="server" CustomValidationMethod="ValidateUserName" />

WebUserControl.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl.ascx.cs" Inherits="WebApplication1.WebUserControl" %>
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Custom Validation Failed" OnServerValidate="CustomValidator1_ServerValidate" />
<asp:TextBox ID="TextBox1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Submit" CausesValidation="true" />
WebUsecControl.ascx.cs
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class WebUserControl : System.Web.UI.UserControl
{
public ServerValidateEventHandler Validating;
protected void CustomValidator1_ServerValidate(object sender, ServerValidateEventArgs e)
{
if (Validating != null)
Validating(sender, e);
}
}
}
TestPage.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="WebApplication1.TestPage" %>
<%@ Register Src="~/WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:WebUserControl ID="WebUserControl1" runat="server" OnValidating="WebUserControl1_Validating" />
</div>
</form>
</body>
</html>
TestPage.aspx.cs
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class TestPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//WebUserControl1.Validating += WebUserControl1_Validating;
}
protected void WebUserControl1_Validating(Object sender, ServerValidateEventArgs e)
{
e.IsValid = false;
}
}
}

I did some research and I found Type.GetMethod and MethodInfo but I can't get them to work. Primarily because I don't know the type of the parent control and can't figure out how to get it. EDIT: My code for matt-dot-net. As you can see it's almost an exact duplicate of your code. For whatever reason it does not work for me as I have it here. When I click on the button the page reloads and is the same. When I un-comment the one line though and click the button then I see the error message.

Posted: Jul 4 10 at 19:56

View 1 Replies!   View Related
WCF / ASMX :: WCF Username Authentication With A Custom Validator?
how to implement WCF username authentication with a custom validator in both client side and server side. I am trying this since last 2 days. but no result.

Posted: Feb 18, 2011 05:25 AM

View 7 Replies!   View Related
No Error Message Displayed For Custom Validator?
I have a requirement that one of multiple fields is required. Using custom validator the even fires, false is returned, but no error message is display and the form validates. What am I missing? I have tried with and without ValidationSummary.

<asp:CustomValidator ID="CustomValidator1" OnServerValidate="validatePhone" EnableClientScript="false" runat="server" ErrorMessage="Home or Cell Phone is Required" ></asp:CustomValidator>
<asp:ValidationSummary ID="ValidationSummary1" DisplayMode="BulletList" runat="server" ForeColor="Red" Font-Size="X-Small" Font-Bold="true" />
protected void validatePhone(object sender, ServerValidateEventArgs e)
{
e.IsValid = string.IsNullOrEmpty(txtCellPhone.Text) && string.IsNullOrEmpty(txtHomePhone.Text) ? false : true;
}

Posted: Nov 3 10 at 22:50

View 3 Replies!   View Related
Web Forms :: Custom Validator - Valid Number?
I am using C#for ASP .NET 2.0. On my web form I have a TextBox that I want to let the end-usertype inside of. The rules are as such: Theyshould only be allowed to type numbers and a decimal.No negative numbers allowed. The number has to range from 0.00 to 24.00 - for hours - and can only allow for quarter hours - example: 0.00, 0.25, 0.50, 0.75, 1.00, 1.25, etc. Do I need a custom validator for this?If so, I do I check to see that the number is valid?

Posted: Mar 12, 2010 06:14 PM

View 5 Replies!   View Related
Web Forms :: 2.0 - Wizard - StepNavigationTemplate And Custom Validator
I have a well-debugged page with wizard control where "Next" and "Previous" buttons are generated by control itself, without template. One of steps contains custom validator shown below:

[Code]....

It's not so important what exactly does it do, moreover as I will show below, it works allright. So, at the moment when we press "Next" button, if this validator tells that data is wrong, Wizard doesn't go to the next step and stays at the same step exactly as it should. Perfect! But today I decided to change Navigation Bar with buttons from standard view, and instead of automatic one I inserted that template (btw, generated by Studio itself, I've just a bit edited it):

[Code]....

[:O] Everything stopped to work! To be more specific - I found after some tests that my validator is called as usual. Moreover, it honestly sets "false" to its' args.IsValid! But ASP.NET ignores it and wizard with no doubt goes to the next step! One .aspx file (I'm not touching .cs one even!). Doesn't work -> just delete <StepNavigationTemplate>...</StepNavigationTemplate> section, check -> everything works ok. Return it back -> nothing is working again. I'm "dazed and confused" (c) What I have to do to force it work the right way?

Posted: Aug 30, 2006 10:24 AM

View 13 Replies!   View Related
Ajax - Custom 'Type' In Compare Validator?
How to reset date Type for Compare Validator in ASP.Neti am using the dd/MM/yyyy format for the Calendar Extender of a textbox, where as Compare Validater looks for MM/dd/YYYY format.so how to change date format of Compare Validator.

Posted: Oct 19 10 at 11:07

View 1 Replies!   View Related
C# - Cross Page Posting & Custom Validator?
I use a Custom Validator (which validates on the server) and a button (it's PostbackUrl = "Page2.aspx").

When I press the button the browser show always Page2 without checking if the page is valid.

Posted: Mar 5 10 at 16:57

View 1 Replies!   View Related
Web Forms :: Can't Have Multiple Instances Of A Custom Validator
I have the current block of code inside an OnPreRender method of a validator that is inheriting from BaseValidator. If I have one instance of the validator this works fine, but if there are multiple instances the javascript flakes out. As it stands the acutal evaluation function has to be rendered on a per instance basis. I know it's kind of a drop in the bucket, but I'd like to register the block below just once instead of giving each instance a unique key to register with.

[Code]....

Posted: Feb 08, 2011 04:11 PM

View 3 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved