C# - Extend The Requirefieldvalidator To Take A New Property And Validate Regularexpressions?

Mar 16, 2011

I'm trying to extend the requirefieldvalidator to take a new property and validate regularexpressions also. I know I can use the RegularExpression control but then i need 2 controls so i want to eliminate it so i only have to use two controls. There are also other features i want to make which include me extending it. My problem is i don't know what to override - i tried the Validate() but i get "cannot override inherited member 'System.Web.UI.WebControls.BaseValidator.Validate()' because it is not marked virtual, abstract, or override" and i understand the EvaluateIsValid() is for validating the control not what is in the control.

[code].....

View 2 Replies


Similar Messages:

C# - How To Extend The User.Identity Property

Jul 30, 2010

I'm not talking about asp.net membership.

For each logged user I want to cache some properties like status or the number of friend requests, from the db.

I can create custom class which would do it but I thought it will be better to extend the existing User.Identity property. Something like this:

Label1.Text = User.Identity.Status;

View 2 Replies

AJAX :: Enable / Disable Field Validation Using RequireFieldValidator And ValidatorCalloutExtender?

Feb 18, 2010

I am creating a fairly straight forward form for collecting data about vendors. I have a requirement that says the email address is required for a certain payment method and not other payment methods. The way I currently have this implemented is using a dropdownlist for the payment method and a TextBox for the email. I have been using ValidatorCalloutExtenders on all the other input fields with great success, but this is the first case where I need to be able to turn the validator and extender behavior on and off based on a selection of the dropdownlist.

I have tried many things and have searched these forums and google until my hands and eyes got tired, but have yet to find success, hence this post. I am aware of the dispose and $create methods, and that is currently what I am trying to do, but after the create occurs, while the behavior has been created, it doesn't seem like it has been created completely or something. To implement this, I am using a function tied to the onChange Event Handler of the drop down list. The function essentially checks the dropdownlist selection value and if it is NOT "ACH", then it finds the behavior attached to the requiredfieldvalidator attached to the email textbox and calls the dispose method on that behavior, if the selection value IS "ACH" then the method calls

$create(AjaxControlToolkit.ValidatorCalloutBehavior, { "closeImageUrl": "/VendorMaintenanceForm/WebResource.axd?d=IJFIM0l1l2KBLbEjcc5eS12jNidTRT60rU5Tz_Vg2CIJnYpw0GWOKDcVthhDzk9qkoREy7KswErAqM-kEQdJ5c18thtoit9YPZB3oq-EKdE1&t=633129167627987742", "highlightCssClass":
"HighLight", "id": 'emVal', "warningIconImageUrl": "/VendorMaintenanceForm/WebResource.axd?d=IJFIM0l1l2KBLbEjcc5eS12jNidTRT60rU5Tz_Vg2CIJnYpw0GWOKDcVthhDzk9qpoLKUlLQVCOCBk1mUhtC-YfwF57Tw0d676WGnnWiYI41&t=633129167627987742", "width": "300px" }, null, null,
$get("ctl00_MainContent_RequiredFieldValidator5"));

The reason I say this, is because once the page loads, the default value is to have the validator disabled, then if I select the payment method that enables the validator, it seems to work fine, but then if I cycle through the payment method choices again, I end up with a null pointer exception to the TextBox element when the validator is trying to apply the highlightCssClass on form validation. So, to summarize, it seems like when the page loads, things get built correctly, but then when I start doing the dispose and $create, things are recreated correctly so that when the submit button click causes validation, the validator throws a null pointer exception.

I know it can be hard to debug this sort of thing using words, but I was just wondering if I am going about this the right way or if there is an easier way to conditionally enable/disable a requiredfieldvalidator and validatorcalloutextender.

View 9 Replies

IValidatableObject.Validate Only Called If Property Validation Passes?

Jan 22, 2011

In my model, it seems that Validate() is only called AFTER both properties pass validation.

public class MyModel : IValidatableObject
{
[Required]
public string Name { get; set;}
[Required]
public string Nicknames {get; set;}
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(Nicknames != null && Nicknames.Split(Environment.NewLine.ToCharArray()).Count() < 2)
return yield result new ValidationResult("Enter at least two nicknames, new [] { "Nicknames" });
}
}

When a user enters a single line of text in the Nicknames text area but leaves the Name text box empty, only the Required error message for the Name property is displayed. The error message that should be displayed from the Validate() function never shows up.

Only after entering a name in the Name text box and some text in the Nicknames text is the Validate() function called.

Is this how it's supposed to work? It seems odd that a user is shown an error message on a subsequent page when the error is being caused on the current page.

View 1 Replies

Validate A Single Property With The Fluent Validation Library For .Net

May 17, 2010

Can you validate just a single property with the Fluent Validation Library, and if so how? I thought this discussion thread from January of 2009 showed me how to do it via the following syntax:

validator.Validate(new Person(), x => x.Surname);

Unfortunately it doesn't appear this works in the current version of the library. One other thing that led me to believe that validating a single property might be possible is the following quote from Jeremy Skinners' blog post:

"Finally, I added the ability to be able to execute some of FluentValidation's Property Validators without needing to validate the entire object. This means it is now possible to stop the default "A value was required" message from being added to ModelState. "

However I do not know if that necessarily means it supports just validating a single property or the fact that you can tell the validation library to stop validating after the first validation error.

View 1 Replies

C# - Validate Dropdownlist Selectedvalue Against A List From Static Property?

Oct 4, 2010

I am using javascript to validate user input on my aspx page. I am easily able to validate textboxes and dropdown list for differenet scenarios.

Now, on one of my dropdown lists (for country), I need to check if it is an allowed country or not for a particular service. I have stored the valid country list in a static property. Is there a way to validate my dropdownlist selected value against that static property?

function validateService(source, args)
{
var country = document.getElementById('<%= ddDestCountry.ClientID %>');
var service = document.getElementById('<%= ddService.ClientID %>');
// Get allowed country list from my static class
var countryList = document.getElementById('<%= StaticProperties.EUCountryList %>');
if (service.value == "P")
{
// I want to do something like this
if (!countrylist.Contains(country.value))
{
args.IsValid = false;
}
else {
args.IsValid = true;
}
}
return;
}

Update(Additional Information): The static property is read-only so it cannot be tampered with from the page.

View 1 Replies

Inheritance - Extend Whole Website In Asp?

Mar 10, 2011

I work in a web agency and thus we are plenty of websites from several customers. They're built upon a cms we made, so websites are quite identical for the 90% of code. However, remaining 10% struggles me and my team as it involves not only the presentation layer but behavioral logics too (ex: a website1 requires simply user/pass registration while website2 needs more data, facebook connector, etc. But this is a very easy example). Making ad hoc development for our customers is becoming painful as keep each version aligned is getting really hard for us What I really dream to have is an extendible website that works by itself, but in which I can override a part. This behavior should sound like "look for the specific part, if it doesn't exists get the base one". The parts could be a method, a class, a page, a control, a static file.

example:
Suppose I want website2 to have an own login component, let's so imagine that we have a situation like:

/website_base
|_ login.aspx
/website1
/website2
|_ login.aspx

So, if I ask for [URL] I'll get /website_base/login.aspx, but if I ask for [URL] I'll get /website2/login.aspx

View 3 Replies

Web Forms :: How To Extend Web User Control

Aug 12, 2010

i have a WebUserControls with 2 file : UCTMyControl.ASCX and UCTMyControl.ASCX.CS

In file UCTMyControl.ASCX.CS i have 1 virtual method Example: Virtual void Hello();

and now in Page example : MyPage.aspx and MyPage.aspx.cs

i want override method Hello() above in Web User Controls

how can i do ?

View 2 Replies

Validation - How To Extend A CompareValidator So Can Check

Jun 12, 2010

How to extend a compareValidator so i can check, if user has written some text in ControlToValidate then he must write some text in ControlToCompare too.

View 1 Replies

ASP Extend Or Add Pieces To Existing BoundField

Nov 5, 2010

Is it possible to add a property to the existing asp:BoundField control without creating a brand new instance to which I'd have to declare <tst:BoundField></tst:BoundField>? If so, can someone provide an example?

View 1 Replies

ADO.NET :: Extend A Project With New Edmx File?

Oct 13, 2010

We are using entity framework and we have two projects with two different edmx files. We need to keep both tables in same database and we want to extend funtionalities of one project by the other one. Is there a way to extend edmx files or is there a better solution for this?

we have 3 edmx files in three class libraries.

1.person class library(Core) with core.edmx-Basic details related to a person(name,email ...)

2.CV Claas library with CV.edmx wich have CV related data(Experiance,skills... )

3.Customer Relationship management system(CRM) which have customer data(sales data...)

Then we want to use core class library edmx file(Core.edmx) with cv.edmx (basically cv tables should be able to use tables from core tables) . Same way we want to use the core.edmx with CRM.edmx for the 3 rd project

View 1 Replies

Security :: Extend The Role Provider?

Apr 29, 2010

Is it possible to extend role provider? like instead of IsUserInRole(username, rolename) can we have a IsUserInRoleFacility(username, rolename, facilityid)

View 2 Replies

Web Forms :: To Extend The Control To Add More Data Fields In It?

Jan 19, 2011

I have two questions on asp.net CreateUserWizard control;

a. Once I put the control on webpage how do I connect the control to the backend db?

b. How do I extend the control to add more data fields in it?


View 1 Replies

Extend Web.config Application Pool Recycling?

Apr 15, 2010

I have noticed how editing the web.config file in an application folder causes that application pool to recycle and pick up the changes.

How does IIS achieve this and is it possible to extend this functionality for another config file? Or is this dependency hard-coded somewhere? This is related to the possiblity of deploying configuration changes to a web server without having to edit the web.config, which is usually maintained by a different team.

Note that I don't want to manually invoke this recycle event, but have it work in the same way as with web.config. I'm aware that I could simply add these settings to web.config, but that's not what I've been asked to do.

View 1 Replies

Handler With IRequiresSessionState Does Not Extend Session Timeout

Oct 6, 2010

I have a handler, like this, using IRequiresSessionState:

public class MyHandler : IHttpHandler, IRequiresSessionState
{
// code
}

In the code, I am able to read and set Session values. I also check ensure that the caller is logged in. That all works fine.

The web site uses forms authentication, so in the web.config, I have this:

<authentication mode="Forms">
<forms loginUrl="Login.aspx" timeout="10" slidingExpiration="true"></forms>
</authentication>

The problem is that AJAX calls from the client to the server code MyHandler do not extend the life of the session!

So even if the user is busy sending and receiving data from the server, they time out 10 minutes after their last full page load.

In the handler, I've tried specifically changing a value is the session on each call, but not even that extends the time out.

View 1 Replies

AJAX :: Extend Autocomplete Control From Toolkit?

Dec 17, 2010

I want to use the all the default functionalities of autocomplete control from toolkit, also want to customise it.For e.g. i want to add few more properties to it or customise the servicemethod parameters.Is there any way to do it?

View 3 Replies

MVC :: How To Create An Extension To Extend The HtmlTextbox Methods

Sep 16, 2010

I am trying to create an extension to extend the HtmlTextbox methods to allow our developers to add onkeydown inline javascript to auto click a button with a name they specify.

[Code]....

View 6 Replies

Security :: How To Extend The RoleProvider To Have Custom Code

Feb 24, 2010

I am obviously missing something here and it is driving me batty. I am trying to implement a custom role provider so that I can add some of my own custom code to it. I have created my CustomRoleProvider class, I have inherited the RoleProvider base class and implemented its members. I have made the required changes to my web.config so that my CustomRoleProvider is used. This is all working great.

All of this is wrapped up in a wrapper class as provided by the MVC Membership Starter Kit that I am using and wish to extend.

Now I want to add my own custom functionality.

When I add a function to my CustomRoleProvider I cannot see it or access it.

How do I add functionality to my CustomRoleProvider so that I can use it?

View 1 Replies

MVC :: Can Extend The HtmlHelper Class From A View Page

Mar 26, 2010

I can extend the HtmlHelper class from a View page but how can I extend its functionality within a class?

[code]...

View 13 Replies

How To Extend The Session Time When There Are Multiple Forms

Jun 28, 2010

How to extend the session time. There are many form in my application like parent and child forms. So how can I make pop up to appear when session times out and the pop up should appear on the form where the user is currently in, when popup comes I have to disable all forms like(they should be transparent (i.e) user should NOT be able to edit them). how can i extend the session when I click on the OK button.

View 2 Replies

C# - How To Extend ListItem To Be Able To Have Childs Inside BulletList

Mar 27, 2011

Using asp.net C#. I have BulletList, and I would like to add ListItem that will render with childs.
That is, inside every <li> I can add more controls to be rendered.

View 1 Replies

C# - Extend AuthorizeAttribute And Check The User's Roles?

Feb 25, 2011

I am busy writing my own custom attribute for my action method called MyAuthorizeAttribute, I am still busy writing the code, here is my partial code:

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class MyAuthorizeAttribute : AuthorizeAttribute
{
public new Role Roles;
public override void OnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);
if (Roles != 0) // Did it this way to see what the value of Roles was
return;
// Here I am going to get a list of user roles
// I'm doing my own database calls
filterContext.Result = new HttpUnauthorizedResult();
}
}

Here is my Role enum:

public enum Role
{
Administrator = 1,
SuperAdministrator = 2
}

My action method:

[MyAuthorize(Roles = Role.Administrator|Role.SuperAdministrator)]
public ActionResult Create()
{
return View();
}

The reason why I did not use Roles = "Administrator,SuperAdministrator" was because the roles are hard-coded. I don't want to have a 100 places to change if the role name changes.

Given my method, when it gets to if (Roles != 0) then Roles total value is 3, how would I check to see if these 2 roles is in the list of user roles for a specific user?

Am I doing it correct here? If not how would I otherwise implement this? It doesn't have to be the way that I did it in.

View 2 Replies

C# - Extend DynamicQuery.cs To Implement A .Single Method?

Mar 28, 2010

I need to write some dynamic queries for a project I'm working on. I'm finding out that a significant amount of time is being spent by my program on the Count and First methods, so I started to change to .Single, only to find out that there is no such method.

The code below was my first attempt at creating one (mostly copied from the Where method), but it's not working.

public static object Single(this IQueryable source, string predicate, params object[] values)
{
if (source == null) throw new ArgumentNullException("source");
if (predicate == null) throw new ArgumentNullException("predicate");
LambdaExpression lambda = DynamicExpression.ParseLambda(source.ElementType, typeof(bool), predicate, values);
return source.Provider.CreateQuery(
Expression.Call(
typeof(Queryable), "Single",
new Type[] { source.ElementType },
source.Expression, Expression.Quote(lambda)));
}

View 3 Replies

Web Forms :: Extend Default Menu Items?

Mar 14, 2011

I'm trying to style my menu and menu items so it looks like a tabbed menu. I've seen really nice css code examples which I want to use in my master pages. Problem is, when you click @ a menu item, the active menu item should have a other css class than the other ones in order to style them. How can I do this? Is there a tabmenu available which is easy to style and detects when a menu item is clicked?

View 1 Replies

Extend QueryableFilterRepeater To Override The Filters Shown?

Apr 21, 2010

In previous versions of DynamicData you could override GetFilteredColumns method from FilterRepeater to manage which columns are used to generate filters.

But now FilterRepeater is obsolete, and his successor QueryableFilterRepeater don't have such method.

There is any way to override the columns used for filtering with QueryableFilterRepeater?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved