Validating a control. Sponsor must be existing user.

Hi

I am trying to create a form for creating new users. A new user has to be sponserod by an existing user. How do I validate the sponsor control? The new user wil put an existing username in the sponsor control when he registers and then the program must check if the user name exists before it continues.

0
mcilliers
5/4/2009 7:54:35 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
1172 Views

Similar Articles

[PageSpeed] 24

Hi,

you can put a CustomValidator on the page and implement your existing-sponsor-username logic within its OnServerValidate event.

If you want to avoid postback, you can add client-side validating logic using ajax and webservices.

This may help:

http://www.codegolem.com/post.aspx?id=7edcaa9d-4476-4a81-b72d-c7edc616f7a6 

Bye!


=WereWolf=
--
MCPD
--
Helping someone does not mean giving them what they need, but making them able to get it themselves
--
The Code Golem http://www.codegolem.com/
0
WereWolf
5/4/2009 9:20:28 PM

The CustomValidator server control is handy for this.  It raises an event called ServerValidate in which you can see if the user is an existing user by implementing your existing security.  So it could be something like this:

<asp:CustomValidator runat="server" id="cusCustomer" controltovalidate="txtCustomer" onservervalidate="cusCustom_ServerValidate" errormessage="You must be an existing user!" />
protected void cusCustom_ServerValidate(object sender, ServerValidateEventArgs e)
{
    if(User.IsAuthenticated)
    {
        if(e.Value.Length == 8)
            e.IsValid = true;
        else
            e.IsValid = false;
    }
}
 

 


Sincerely,
Malcolm Sheridan
Microsoft Certified Solution Developer
Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as
Answer" if a marked post does not actually answer your question.
0
malcolms
5/4/2009 9:26:42 PM
Reply:

Similar Artilces:

validate Textbox in Web User Control from web form?
ASP.NET 2.0 I have a web user control that contains a textbox.  I need to add some validation (like requiredfieldvalidator, comparevalidator, etc). I would normally add the validator to my web user control by placing the validator next to my textbox.  However, I need the validation message somewhere else on my web form, not near the user control. So how would I associate a validation control on my web form with the text box inside my web user control?  Can this be done; any alternatives out there? Thanks!   The error message should occur wherever you place the vali...

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...

Web User Control to Web User Control...
Hi, I have 2 User controls on a page and want Control1 to call a method of Control2. Is this Possible? Example: Con1 = Datalist showing products, each with a Quantity Box and a Button. Con2 = Repeater showing Cart Preview (name, Price) in page.aspx. When I click on the button on the DataList in Con1 it adds the item into the Session based Cart. However it does not update the Cart Preview. I need to call BindPreview() in Con2 in order to update the Cart Preview... Does that make sense? argh! any help much appreciated! PeteWeb Design Nottingham, UK Well I can call BindPreview() from m...

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...

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...

validation and tabindex of custom user control on web forms
Hello - I recently created a very simple user control which is a drop down list containing department names I read out of a database. When I drop this control onto many web forms I've created, I'm not able to set the tabindex or connect a validation control to validate an item was selected from the list. My code is VB.Net and would appreciate any help. Thanks. I'm guessing that you are attempting to connect a validation control to the USER CONTROL. It should be connected to the DropDownList control. So make a property on your user control that exposes the DropDownList. Now you can int...

Web Form and Web User Control
Hello, I have a Web User Control (ascx) that includes a button. This button has an onclick event method. This Web User control is included into a Web Form. (thru LoadControl). However, when I click on the button, the event method is not executed. What should I include in order it works fine? Thanks in advance. GAA. Using Loadcontrol is using dynamic controls and when using dynamic controls you must recreate the same dynamic controls ono postback to econstruct the page control tree. It is best if you do this during the Page PreInit event. How complex are your controls ...

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...

Assign a Web user control to a Validation Control
I am trying to add a user control built in 1.1 to a 2.0 web page. The 1.1 user control already has validation built into it. I need to use validation groups on the hosting page. Since I cannot assign a validation group to the user control, the built in validation does not run. Is there any way to make this user control work with validation groups?   How is it that validation is already "built-in"? Can you just duplicate the validation logic in a new validator on your 2.0 page? There is a validator on the the user control: Public WriteOnly Property EnableValidat...

Wizard
I have a wizard with a few steps. One of the steps contains a web user control with 3 text boxes. I'd like to validate that these text boxes have data before allowing the user to go to the next step. I tried putting the requiredvalidators inside the web user control - but these arent fired when the Next button is clicked. I tried putting the requiredvalidators on the Step page itself but cant wire them up to the web user control. Whats the correct way to do this ? Hi, Would you please post the code of the ASP.NET? I will be waiting for your feedback. Hong GangHong-Gang ChenMicroso...

custom web user control and web form
Guys,          I am trying to develop a context menu control for all of my pages. what i am trying to do is that i want the control to pick a datasource from the markup and then check whether its an xml file or a datatable. I created a class called datasource.   /**************************DataSource Class****************************/  public class DataSource { /// <summary> /// This is to identify unique elements from the markup /// </summary>protected string _ID; /// <summary> /// This will be the Datasource ID e...

Web User Control Not rendering in Web Form
I have created a Web User control that is made up of a Multiview with 2 views inside the Multiview. I have buttons on both views and a gridview on 1 view. My question is when I drop this Web User Control on a Web Form all I see is [MultiView"MultiView1"] and when I view the from in the browser I dont see the Web User Control. I was wondering if someone could please tell me why the Web User Control is not displaying or rendering.     Thanks In Advance Hi, Please check your aspx file for correct reference, like following example: TestControl.ascx:<%@ Control ...

Validating web user control(ascx) in parent page (aspx) -- .NET 1.1
Hi,  I have a user control which has some asp.net server controls like drop down list, list box etc. These fields are required. I'm using this control in a parent page which has its own server controls which are also required. The button on the parent page which is supposed to validate the controls is not working after I add the web user control.  Is there a work-around for this scenario  other than manually calling Page.Validate() and checking for Page.IsValid property ? I tried calling a javascript on button click which calls Page_ClientValidate() whic...

User Controls not working if I put Validation controls in user control
Hi           I have validation controls(RequiredField Validator,RegularExpressionValidator)  in user controls.User controls are not posting back like the events are not wiring up.If I remove Validation controls in User controls page,user controls are working fine.Can anyone please help me out in getting it fixed. In the Validation controls, make sure you are setting the ControlToValidate property to the control that it links to.  If you're in .NET 2.0, it's also a good idea to put all the validation controls in the same Valid...

Web resources about - Validating a control. Sponsor must be existing user. - asp.net.web-forms

Talking to police about Ghomeshi allegations was validating: Decoutere
One of the women accusing former CBC host Jian Ghomeshi of violent behaviour is encouraging other potential victims not to be afraid of speaking ...

Validating Input and Interprocess Communication
Describes techniques to use and factors to consider to make your code more secure from attack.

Validating team-by-team R and RBI predictions for 2012 AL Edition
Unless you're a big fan of my writing, you may not know that at this time last year, I wrote for a different SB Nation site: the dearly departed ...

"It is important not to create a precedent validating the prohibition of the sale of any object of a ...
"... regardless of the culture concerned... Our goal has always been to showcase Hopi culture and make it accessible to the largest number of ...

Validating the Donald
Validating the Donald by digby In Salon today , I wrote about the right wing media's immigration backlash strategy by validating Donald Trump's ...

Validating your marketing audience
... enjoyed this, please share it with your network! Want to read more like this from Christopher Penn ? Get daily updates now: The post Validating ...

Validating Albert Einstein, physicists make major discovery about the early universe
In the beginning there was the Big Bang. What we know about this time is that the universe was extremely hot, dense and almost uniform; it was ...

Validating Architecture through LINQ Query
... is simple enough to get validated at a glance. But at a glance is not enough. What about defining custom rules that take care of validating ...

From Data to Action – Best Practices for Validating and Optimizing Your Digital Campaigns - comScore ...
In this webinar, comScore Senior Industry Analyst Jason Patterson explores how you can use comScore's validated data to optimize and improve ...

TDD of a WinForm app – Part 5 – Validating the account data
In our last post, we worked on allowing our user to enter new accounts – basically making our AddAccountForm usable. We were able to do that ...

Resources last updated: 12/18/2015 6:35:29 AM