Web Forms :: Adding Validators To Custom Controls?
Jan 15, 2010
I'm attempting to create a custom control that extends the Table class. Inside of the table will be rendered a number of different controls based on a specified identifying property. On some of these controls, however, I need to specify validation for data types and requirement. To me, the most logical way of doing so is to add validators to the table and set their appropriate properties to specify which controls to validate. In doing so, however, I've discovered that none of the validators added will even render on the page in which the control is added. So is this a valid construct?
Here's an example of what I mean:
[Code]....
End result? No validation. So what's the move?
View 4 Replies
Similar Messages:
Jan 14, 2010
I'm attempting to create a custom control that extends the Table class. Inside of the table will be rendered a number of different controls based on a specified identifying property. On some of these controls, however, I need to specify validation for data types and requirement.To me, the most logical way of doing so is to add validators to the table and set their appropriate properties to specify which controls to validate. In doing so, however, I've discovered that none of the validators added will even render on the page in which the control is added. So is this a valid construct?Here's an example of what I mean:
[Code]....
View 1 Replies
Apr 21, 2010
I am using two custom validator to validate EMAIL (should not be reused) & a captca image (text).Everything is working fine except that the displayed are not dynamic even though I set the displaystatus as DYNAMIC.
Test:
1. Enter email already registered
2. Enter invalid captcha text
both displays error. fine for now. but again.
1. Enter email NOT registered
2. Enter invalid captcha text
the error message at the email is still displayed as 'the email is arlready registered'. How can I remove the message for the email?
View 10 Replies
Jun 17, 2010
I would like to find a way of running custom validation on a checkbox list. The reason why is because they were a radiobutton list. Then our client decided they wanted to be able to uncheck them (without a clear button) so in the end I had to change them to checkbox lists and make them mutually exclusive. On some of them, one must be selected and I downloaded this: [URL] to set them as required - worked nicely. Perhaps there's a way of building on this further to create some sort of custom checkbox validation. why I need this custom validation is because when the built form checkbox list = flat or maisonette then floor level is then required.
View 3 Replies
Oct 20, 2010
I have custom gridview that inherit from the regular gridview.
On of the features is that is has a built in page size dropdown in an extra header row.
Another feature is that this extra header row has a place holder where aditional controls can be added but here is where I have some problems.
When I add a control that is created outside the gridview to the gridviews builtin placeholder and tries to do anything that performs a postback the gridview dissepears, but appears again on a new post back.
Here is the code for the gridview:
[Code]....
And this is the way it is used in a usercontrol on page, the gridview is called gvList and the control that I try to add to its placeholder is the phrExtraHeaderControls:
[Code]....
What can be wrong, is the viewstate messed up in the postback so that the gridview can't be rendered?
View 1 Replies
Mar 3, 2010
All ASP.Net client validation messages can be shown as an alert by setting the ShowMessageBox="True" property on the ValidationSummary control. This works fine for anything that happens on the client.
For the custom validators that validate server-side I had assumed that what would happen is that when the page is returned to the browser, ASP.Net would inject some javascript to show the alert box. However this isnt the case.
If you had relied on the message box to show detail and just have a * next to the erroneous field (as per my clients req's) then it wont work as intended. Does anyone have a solution for doing this? What I want is a way to possibly override the ValidationSummary control to inject javascript onto the page or something like this.
View 1 Replies
Aug 5, 2010
Wanting to create custom data annotation validation. Are there any useful guides / samples on how to create them?
Firstly: StringLength with minimum and maximum length. I'm aware .NET 4 can do this, but want to do the same in .NET 3.5, if possible being able to define minimum length only (at least x chars), maximum length only (up to x chars), or both (between x and y chars).
Secondly: Validation using modulus arithmetic - if the number is a valid length, I wish to validate using the Modulus 11 algorithm (I have already implemented it in JavaScript, so I guess it would just be a simple porting?)
Update: Solved second problem, was just a case of copying over the JavaScript implementation and making a few tweaks, so don't need a solution for that.
View 1 Replies
Mar 24, 2011
I'm working on a page that has a significant number of textboxes/dropdowns/etc to fill out. The majority of these are going to be performing some sort of custom validation. I should note that it's nothing of substantial size - all just string or integer values.
I always hear (and have typically always agreed) that as much validation should be performed on the client rather than on the server, but in this case I am unsure. The difference here is that this project will be passed on to an IT guy who knows about computers but is still new to programming - he will be the one in charge of making the minor updates and changes to the way these custom validations work in the future.
My idea shifted from being as efficient as possible to being a bit less efficient but much more readable. I created a new class specifically for all of my validations which will be used throughout the website. By forcing all of my custom validation code in this class, though, I eliminate any client-side validations I might be able to perform. I should also note that each page that requires a custom validation will generally need to perform at least one server-side validation, so I will never be able to use client-side 100%
Considering the relatively low level of activity on the website (currently and in the future), would you consider this as an acceptable solution? Or would you ALWAYS prefer to have as much validation on the client as possible in order to increase the responsiveness, even if it makes things a bit more messy for whoever may be working on it in the future?
View 2 Replies
Jul 21, 2010
I have a page where I am using 2 update panels. The first update panel contains a form that has some validation tied to it. The second on has a simple form, but no validation. When I go to use the form in the second panel, the postback is halted by the validators in the first panel. Everything works as it should when I remove the validators.
View 2 Replies
Dec 27, 2010
I have Create a Custom Principal and a Custom Identiy for my Web Application and upon forms authentication
1 Create a profile of type object
2 Assign it to the Principal profile
3 assign the principal to the Http.Current.User (this now has the complete profile information )
As i understand upon redirection the principal is recreated and i loose the information i had stored in the profile.
I there a way to persist the profile information ?
I though can achieve persisting some information using FormsAuthenticationTicket in userData but that wouldent solve my purpose ..
View 7 Replies
Apr 14, 2010
We're trying to build a simple asp control for some clients where they can just drop in a single block -i.e.
<captcha:CaptchaControl ID="CaptchaControl1"
runat="server"
Server="http://localhost:51947/"
/>
and have it render the control. The catch is that I can't get this to include custom validation. Right now I'm using the RenderContents function to display the layout of the control itself as well as hook it up the to Javascript. The problem is that I don't know how to get custom validation to fire when used as part of a control.
[code]...
View 2 Replies
Mar 13, 2010
i create a custom control which can hold some templates, such as Header, Body Footer, etc.
[Code]....
i tried to use smarttags to allow the user to edit each of the templates, which worked pretty well. what i could not get working was to add a template if it has not been in the control. eg. add a header-template to the control above. i tried using the RootDesigner.AddControlToDocument() function of my controldesigner. but this function gives me an error, telling me the control i'm going to add the template (i used a new HtmlGenericControl("HeaderTemplate") as new Control) to is not valid. (i can't give the exact error message, cause i use a german version of visual studio 2008) i've been searching the web for nearly half a day now, but i did'nt find a working solution for my problem.
View 2 Replies
Jan 10, 2011
Does anyone know where I can find some info on how to support data binding in my control? I would like to get data primarily from a sql server.
View 3 Replies
Jun 12, 2010
I have a user control that consistes of a dropdown menu, a label, a textbox and a button. It resides in a html table, what i would like to do is on a keypress, such as the "insert" key, i would like to add the same control again directly on the next row, I have used programs that do this, but for the life of me can't figure out how its done...
View 1 Replies
Jan 21, 2010
Scenario:
I have a Gridview where I want to handle the Sorting in a custom control that I've added to the header.
I've added this control to my GridView's Header via OnRowCreate event handling. I want the Sort Expressions to persist session to session (via Webparts Personalization)
Here is what I have for adding the custom header control to the GridView Header
[Code]....
This works out well for adding the control, but I can't get anything to persist because these controls are creating initially via postback (per the event) and re-created on all subsequent postbacks. I can't add an If(!IsPostback) because the controls are initially created on the gridview's postback (well at least thats how it's acting when I put it in there) If I were to add this control via the ASP page, not via the Codebehind, I would be able to persist the control. If I try to treat it as though everything is setup correctly, and assign my custom control's controls to [Personalizable], I get a runtime error telling me that I can only have webpartzones in or before Page_init (I'm guessing this is due to when/where the
gridview hits the OnRowCreate event). If there is some fundimental logic I'm missing, or best practices that I'm moving away from,
View 1 Replies
May 13, 2010
[VS 2010 RC1, .NET 4.0, VB.NET]
I'm working with a simple UserControl someone at my company created. It's basically just a DropDownList with a RequiredFieldValidator and some added properties (such as "Required", which controls the CSS styling of the DropDownList and whether the RequiredFieldValidator is Enabled or not).
Here is an example of the UserControl usage where a SqlDataSource is used to populate the ListItemCollection. I'm trying to specify an intial ListItem below (and would like the ability to add multilple ListItems if necessary) but can't seem to get this to work...
[Code]....
My code-behind looks as follows:
[Code]....
I've found several posts related to this but cannot seem to get the declarative ListItem to be added to the DropDownList.
I understand that using a WebControl is another option, but I'd like to learn how to get this method to work if possible.
View 5 Replies
Apr 26, 2010
The built in Asp.Net Controls (label, Textbox, etc.) all have a CssClass property that can be set, what do I need to do to implement that for a Web User Control?
I know how to add a property and pass thru the get & set to the corresponding Asp.Net control (example if I have a label I know how to create a LabelCssClass property that provides a get & set, but the control itself how do I set a CssClass or ClassName property.
View 4 Replies
Mar 2, 2010
I have developed a User Control in inline code model and convert this into dll and try to add it into Visual Studio ToolBox. It shows error "There is no component found in the object.". It is showing actually because i have not added ToolBoxData attribute just before the class declaration, because there is no class declaration in the inline code model. I don't know where i have to add ToolBoxData attribute.
View 1 Replies
Jul 19, 2010
Is there a way to add custom attributes to @Page directive and also get design time support like intellisense for the same?
I have used Adding Custom Property to Page Directive in ASP.Net 2.0 as a pointer.
I would like to have a attribute which will give dev an option to select value from list. Something similar to EnableSessionState attribute. I do understand I need to define an enum for the values. But I cannot understand how to make it available during the design time.
View 1 Replies
Jul 10, 2010
I am extending the TextBox class to include CustomValidator along with the TextBox. I have created properties like CSSClass for ErrorMessage, CustomErrormessage for ErrorMessage on failure. But I am not sure how to get server side validation method in the form of tag. Example:
<asp:CustomValidator runat="server" id="custPrimeCheck"
ControlToValidate="txtPrimeNumber"
OnServerValidate="PrimeNumberCheck"
ErrorMessage="Invalid Prime Number" />
PrimeNumberCheck is the method name which is passed as parameter, same way I want to pass method in my custom TextBox for CustomValidator to run on server side.
View 1 Replies
Mar 22, 2011
I am trying to build a custom composite control, which allows me to add custom content to each child control. It's a similar concept to what you have with a GridView and TemplateColumn. The markup used to place the control on the page would end up being something like this:
[Code]....
I have the code below, which allows me to put that markup on the page without throwing any errors, and it renders all the correct HTML, except it doesn't render the contents of the ColumnTemplate. I have replaced the Render() code with a comment because it's quite long winded and doesn't add anything important here:
[Code]....
I have tried to follow examples on MSDN and other forums but I can't make this work. I think I'm missing the code to render the contents of the template, but I don't know how to hook that up.
View 1 Replies
Sep 23, 2010
I want to add a custom attribute to an asp.net RadioButton called Key which I'm using client-side for an ajax request.
What I'm finding is that my aspx markup which is the following:
<asp:RadioButton ID="rdoPost" GroupName=PreferredContactMethod" value="Post" onclick="DoStuff(this)" runat="server" />
gets rendered in the page as<span Key="ContactMethod">
<input id="rdoPost" type="radio" name="PreferredContactMethod"" value="Post" onclick="DoStuff(this);" />
</span>
whereas I'd expected (and hoped) to get the following
<input id="rdoPost" type="radio" Key="ContactMethod" name="PreferredContactMethod"" value="Post" onclick="DoStuff(this);" />
I've tried the same thing with an asp TextBox control and it works exactly as I'd expect simply adding the Key="myKey" attribute to the <input type="text"/> element.Is there a way around this with the standard RadioButton control, or will I have to inherit from the standard one to achieve the markup I'm wanting? Currently I'm using these attributes in JavaScript in the following way:
var key = rdoPost.Key;
View 1 Replies
Oct 19, 2010
I am using the Entity Framework for the first time and want to know if the following is possible - I have generated my classes from the DB, and have one called Category.
Obviously it has all my fields in the table (ID, CategoryName, SortOrder etc..) but I want to know if I can add a custom property which is not in the table, but is actually the result of a custom method.
I want to add a new property called 'CategoryURL' which is basically the 'CategoryName' property run through a custom method and returns a hyphenated string.
My initial thought is inheriting from the generated Category class and creating something like this inside?
public string CategoryURL
{
get{ return MyCustomMethod(this.CategoryName) }
}
Is this the correct approach? And will 'this.CategoryName' work as I think it should? Basically the end result is when I return a list of 'Category' I want this to be part of the class so I can use it in my foreach loop.
View 1 Replies
Feb 23, 2011
I am attempting to customise the CreateUserWizard by following it in my book, but when I come to reference them in code behind I get an error saying 'FieldName is not declared' for each field i'm adding, they are present in the page with the correct ID's, am I doing something wrong?I am only trying to add a firstName and lastName field to the bottom of the CreateUserWizard and remove the need to a security question.
View 1 Replies
Mar 29, 2011
I've currently got Windows Azure AppFabric system set up and running with my own registered Namespace, in which uses the Google/Yahoo/Windows Live STS providers. That all works fine, I can use them and login to my application. Easy.
However, I can't find anything in any way useful on the web that related to adding my own STS to this list from a 3rd party supplier. I've read that it's possible, and it's the last hurdle I'm stuck on here - replacing the Google/Yahoo/Windows Live STS with the ones I need my application to authenticate with. I cannot find anywhere in the STS control panel to allow for this (AppFabric Labs).
View 1 Replies