Changing Value of Control Before Validator Control access it

Hi,

I'm using Validator controls to validate inputs in the ASP .NET Server controls.

Here, I want to change the values input by user before it is read by validator control for validation.

e.g. I have TextBox1 and It can take only numbers between 400 to 800. So, I have placed a RangeValidator.

But, I need to apply some change to the value. User has put input as "Six Hundred",...so I need to change this to 600 before it's passed onto validator control.

Another example is I need to convert all characters to capital, or I need to remove all spaces or I need to replace all '-' with '/'...before validator control reads value from this control.

How can I achieve this? Even AJAX technique is welcomed. 

P.S. I'm creating a web-form where-in I add controls dynamically(panel.controls.add())...

Thanks you,
CDP
.NET Solutions and Resources Blog

0
cdpnet
9/4/2007 12:17:21 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

3 Replies
674 Views

Similar Articles

[PageSpeed] 16

since validation start on submit button click so u can place ur logic on event like "onBlur" on the textbox , add an attribute for onBlur and specify the JS function to be fired.


No body is perfect, I'm nobody
0
saifi_hasan
9/4/2007 5:39:14 AM

 Hi Saifi Hasan,

I guess your answer is perfect. But, I'm afraid that I want to do this in ASPX Code only. 

Thanks. 

0
cdpnet
9/4/2007 4:30:36 PM

cdpnet:

 Hi Saifi Hasan,

I guess your answer is perfect. But, I'm afraid that I want to do this in ASPX Code only. 

Thanks. 

 

Hi cdpnet,

Based on my understanding, using JavaScript to solve this problem it the best way.

I am using the event.keyCode to solve the problem, see the code; Please look at the part of "bold" and "comment":

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Demo.aspx.cs" Inherits="Demo" %>

<!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>Demo</title> 
  <SCRIPT   LANGUAGE="JavaScript">  
  function   ValidateInput(){  
  if((event.keyCode>=48&&event.keyCode<=57) // if the input is a number, return true.
  return   true;}  
  </SCRIPT>
  </head>
<body>
    <form id="form1" runat="server">
    <div>
  <asp:TextBox ID="txtNum" onkeydown="return ValidateInput()" runat="server"></asp:TextBox> 
  <asp:RangeValidator ID="rvNum" ControlToValidate="txtNum" ErrorMessage="*" runat="server" MaximumValue="800" MinimumValue="400"></asp:RangeValidator>

     </div>
    </form>
</body>
</html>

 

Please correct me if I have misunderstood your mean, please LET ME KNOW. Thanks,

Hope it helps,

Hong Gang

 

 


Hong-Gang Chen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Hong
9/5/2007 2:20:17 AM
Reply:

Similar Artilces:

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspxSSNPlease remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

Validation controls are triggereing other forms validation controls?
Can someone please look at this an explain whats going on. When you click on subscribe it triggers my registration form validation controls. I'not sure what "subscribe" is supposed to do, but if you dont want it to cause validation, set the CausesValidation property to false.Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/ Make sure the feild is an email address Hey coolkidsonly, your initial posting didn't show us anything to look at. We are just guessing here without the specifics. However, m...

How to validate controls on a .NET 2.0 Web user Control
Hi Guys, (ASP.NET 2.0 / C#) I've looked thorugh every post on validating web user controls (and know about Pter Blum's Professional Validation and More package) - but can't seem to get my head around whre to start. I have a web user control, called wucICL.ascx on a we page called AddEditInvestment.aspx.  I would like to validate a couple of DropDownLists (ddlAccounts and ddlContacts) when the Insert and Update buttons are clicked on the AddEdit Investment page. The other controls on the AddEditInvestments page belong to a validation group called All Validators and the DropDownL...

values of web controls in user control can not be access from other pages???
I have aspx page(brief code: includes ascx file) <%@ Register Src="reseller.ascx" TagName="reseller" TagPrefix="uc1" %> <form id="form1" runat="server"> <uc1:reseller ID="idreseller" runat="server" /> </form> the code for asxc file . i have the PostBackUrl to reseller.aspx <asp:TextBox ID="txtPostCode" runat="server" CssClass="form1" Width="50" MaxLength="4" /> <asp:ImageButton ID="ibtn"  ImageUrl="images/searchbutton.jpg" PostBackUrl="~/reseller.aspx" runat="server"  /> In my reseller page i try to read the post value of control txt...

when loading a previously created record on to form, some controls are missing values(controls are depended on values selected in other controls)
Hello - I have created a page for Editing records.  this page will open up a chosen record and allow user to edit the data.On the form, I have 3 drop down lists.   The second dropdown list should fill values depending on value chosen in first dropdown list.  The third dropdown list should show/fill values depending on value chosen in second dropdown list.So taking this into count, i have several records with various data.  When I open-up/load a record in Edit form, only the first dropdown list has a value selected that was the pre-existing va...

Accessing server control values of a web user control from ASPX page
Hi, I have created a web user control (ascx) page with several server controls and the web user control included in a aspx page. I have a command button in main aspx page. How can I access values of the controls in web user control from onclick event of the aspx page. Thanks, Chamil. Make the controls on the web user control public.Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! Could you pl. give me a sample line of code on how to make the control public. thanks, chamil Are you developing inline or with a code-behind?...

change layout of web controls in web user control
Hi I have create a user control with 3 asp:textbox in it. I would like to reuse the same 3 textboxes in 2 seperate web pages. In one case I want them to appear in  a row (as search parameters) and in the other I want them to appear in a column(to add a new object)..  Can I do change layouts using CSS or something? Hi,    Here is a solution to your question for your reference. Create a web user control as the following <%@ Control Language="C#" AutoEventWireup="true" CodeFile="DynamicalUserControl.ascx.cs" Inherits="DynamicalUserControl" %><asp:Panel ID="...

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal ...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

Passing values from a parent web control to child web control
I have a parent control which called CONTROL1 and a child control witch called CONTROL2 I would link to pass a value from the parent control to the child control. In the parent control(CONTROL1) I have the following Event Handler . private void btn_Handler(object sender, EventArgs e) { …      if (Page.IsPostBack) {              // Send the officer names to the child controls.             if(m_nameList.SelectedItem.Text != "")     ...

Web control in web control
Hi,There are two simple web user controls A and B, where B contains A. They just display the bunch of text boxes, so I do not need them even in tool pane. They sit in the same project next to web form.I noticed that web user control put on ASPX page does not appear in code behind, but if I create it with protected keyword and name being exactly the same as id it works fine. I can access such a web control from code behind and see the value assigned in IE. The problem is that the same routine does work for my A web control in B. When I assign the value IE, I keep getting null reference. ...

Web resources about - Changing Value of Control Before Validator Control access it - asp.net.web-forms

CSE HTML Validator for Windows (Official Site) - Powerful HTML Validator, XHTML Validator, CSS Validator ...
CSE HTML Validator is a powerful and easy to use offline HTML, XHTML, CSS, JavaScript, and PHP syntax checker, HTML validator, XHTML validator, ...

DNSSEC/TLSA Validator
DNSSEC/TLSA Validator is a web browser add-on which allows you to check the existence and validity of DNS Security Extensions (DNSSEC) records ...

Feed Validator for Atom and RSS
F E E D Validator for Atom and RSS and KML Jump to navigation RSS Profile Support Added ( more ) Home · About · News · Docs · Terms Copyright ...

iValidCard - Credit Card and Debit Card Number Validator on the App Store on iTunes
Get iValidCard - Credit Card and Debit Card Number Validator on the App Store. See screenshots and ratings, and read customer reviews.

Not fare: new myki card validators lack account balance information
New myki card validators will not tell passengers what their fare is, nor their account balance, leaving unable to monitor their myki use as ...

Mozilla launches new JavaScript-based Add-ons Validator for developers
... that the validation tool provided by Mozilla is unreliable and difficult to use. Today the company announces that the old Python-based validator ...

Business Insider Built An Awesome Analytics Validator And You Can Use It
At a fast-growing media company like Business Insider, keeping accurate analytics is absolutely essential. Editors rely on our analytics dashboard ...

Jon Voight, Validator of Right-Wing Frenzy
Jon Voight was once known for his acting chops and, later, for fathering Angelina Jolie. These days? Well, he's known for his rabid right-wing ...

chriso/validator.js · GitHub
validator.js - String validation and sanitization

Bing Webmaster Tools Adds Markup Validator
The Bing Webmaster Blog announced they have added a new feature to the crawl section named Markup Validator. To access this new feature, login ...

Resources last updated: 11/25/2015 8:34:25 PM