C# - Custom Validation Through Web-method?
Sep 8, 2010
For validating login field (at register form) I use customValidator
<asp:CustomValidator id="uniqueLoginValidator" class="validator" runat="server" ControlToValidate="tbUserName" ErrorMessage="Login duplicate" ClientValidationFunction="LoginValidate"/>
For validate login I need consume wcf, so decide use web-methods
<script type="text/javascript">
function LoginValidate(oSrc, args) {
var login = $(".loginField").val();[code]....
For successfull validating I should setup args at ClientValidationFunction, but I get result validation only at callBack. So how can I setup args for validation work.
View 1 Replies
Similar Messages:
May 19, 2010
I am trying to create a custom password validation attribute which has these requirements
1. cannot be empty.
2. doesn't contain space or other special chracters, which I'll define later.
3. length is between 6 - 12
[Code]....
it works fine on the server-side but I'd like to make this work on the client side as well, so I created a PasswordAttributeAdapter class
[Code]....
and in global.asax I added
[Code]....
View 6 Replies
Aug 28, 2010
Custom Validation Attribute is not called by validation mechanism?
[Code]....
ViewModel
[Code]....
View 3 Replies
Jan 13, 2010
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]....
View 2 Replies
Nov 29, 2010
I am creating a custom control by inheriting a server control, say LinkButton. There are properties like "BorderColor" available in LinkButton. Let's say, I don't want this particular property to be available when I create an instance of the custom control.
I want to completely hide this particular property (I don't want to override it but disable it.)
My code is as follows:
[Code]....
View 3 Replies
May 25, 2010
I've got a custom control with asp:hyperlinks that's causing validation which I don't want... Is there anyway I can stop this from happening?
View 1 Replies
Apr 21, 2010
I have created my own custom role provider class "SGI_RoleProvider" and configured properly.
Everything is working fine.
Suppose that I have added a public method say "SayHello()", then how can i call that. Because if i am using Roles then the method is not displayed. If i am forcefully using that Roles.SayHello() then compiler gives the error.
how can i call this. Because creating a new instance of SGI_RoleProvider is meaningless.
View 1 Replies
Mar 12, 2010
When to go for custom validation control and when to do validation in javascript? What are pros and cons of each of them?
View 3 Replies
Feb 17, 2011
I have created a custom control as can be seen below. this custom control will be used by alot of web form. The question is how to override CheckAllData method in each webform, so i can write my own checking in each webform.
[Code]....
View 5 Replies
May 17, 2010
I am creating custom server control. I have two classes in project. One is main class that render control and another will be used to render content based on condition.I just want to know how to render content from other classes in main class.For example. This isjust an example.My main class code
[Code]....
My TopLeftPane class
[Code]....
My page code on page load event
[Code]....
When I run the page, Header title always getting null. This is a just sample code. I will have more than 20 classes so I dont want to write a code in main class to render whole control.I hope all of you understand my problem.
View 3 Replies
Oct 10, 2010
Is there a method in jQuery that I can customize an invalid validation myself instead of using jQuery plug-in validation?
For example, if the form is valid do this below.
$('form').validate();
if ($('form').valid()) {
//do something
};
But if I wanted to have a cutomize invalid method I could do this below.
$('form').validate();
if (!x == y) {
$('form').valid() = False; //[:(]
alert('Form is not valid.');
};
View 1 Replies
Apr 4, 2011
I was trying to write a method to be called from a CustomValidator to determine whether a string property was unique or not. I was trying to make it generic so that I can reuse the code for many different string properties. I'm using reflection. Does this seem like a way too complicated way of doing this? Does there happen to be a better way of doing this but still making it generic?
public virtual bool IsPropertyUnique(T entity, string newValue, string propertyName)
{
var values =
Context.GetTable<T>.Where(e => string.Equals(e.GetType().GetProperty(propertyName).GetValue(e, null), newValue)).ToList();
return values.Count == 0;
}
View 2 Replies
Mar 15, 2010
I have a problem to use jquery Plugin/Validation.I want to add a method and follow the documentation but I think I still missing some thing.First I add the method but I think I have a problem to implement it.
<script src="js/jquery-1.4.1.js" type="text/javascript"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
[code]....
View 1 Replies
Jun 30, 2010
I am new to this MVC and have a basic question related to validation. I have a create view for customer and based on the customer entity partial class metadata, I am validating the user input and its working fine as expected when the user clicks the create button.I also have a search button in the same create view, which is used for auto generation of some of the field values. When the user clicks the search button the action method create (post) is called with the corresponding button value as argument.the issue here is when the user clicks the search button most of the user input fields will be blank and the validation fails because of that.
View 4 Replies
Aug 21, 2013
I have a validation method,
public string ValidateField() {
string strtemp = "";
strtemp += ValidateField("Visitor_Name", visitor_name.Text, 10, 50, "string", true);
strtemp += ValidateField("Phone_Number", phone_number.Text, 5, 20, "string", true);
strtemp += ValidateField("Contact_Number", contact_number.Text, 4, 25, "string", true);
strtemp += ValidateField("Visited_Date", DropDownList1.SelectedValue, 1, 30, "int", true);
//strtemp += ValidateField("V_Id", v_id.SelectedValue, 2, 35, "int", false);
[Code] ....
And inside the button click event the validation working like
if (ValidateField() == "") {
output = usbll.insertBAL(userval);
Response.Write("Record inserted successfully");
}
It is working correctly...But It is not showing error message.So how to show the error message that is returned from the above condition ValidateField()...If the condition not satisfied i want to show a error message like length should be greater than or equal to minimum length and so on ..
View 1 Replies
Mar 8, 2010
After this JavaScript Method runs the validation controls not work
[Code]....
function checkValue2(item) {
View 2 Replies
Jan 10, 2011
I have added the UDF in my excel template(C#) using excel addin classlibrary,but i can not use that function in custom validation when i use the UDF in custom validation of xcel(data->validation->dropdownlist(custom))i get an error as:
You can not use references to other worksheeta or workbooks for data validation criteria.
Is there any solution to this this problem? Can we use UDF in custom validation of excel...?
View 1 Replies
May 20, 2010
I have just started using MVC2 in VS2010, and I noticed that on the Register page DataType.EmailAddress doesn't actually do any validation, so it does not check whether or not the Email Address entered is valid. Should I write some email validation code in the HttpPost Register method of my AccountController, or is there another way to do this?
View 1 Replies
Feb 3, 2010
I have a custom control that is based off the gridview control located at: here The control is basically a gridview that automatically creates a column of checkboxes that can be used to "check" individual rows in the gridview. During the gridview's "CreateColumns" event, the "checkboxcolumn" is created dynamically. The checkboxcolumn also contains another checkbox in the header that is used to "select/deselect all" checkboxes in the column. Since the gridview does not automatically remember the state of the checkboxes in the checkboxcolumn on postback, I added a method to the control called "SaveCheckBoxState" which stores the indexes of the checked rows in Viewstate, and then I modified the "OnRowDataBound" event to check the Viewstate and reset the checkboxes based on the Viewstate.
I then added a call to "SaveCheckBoxState" in the gridview's OnSorting and OnPageIndexChanging events. This works great so long as I'm sorting or changing pages. However, I need it to update the viewstate everytime someone clicks or unclicks one of the checkboxes. At this time, the checkboxes are rendered with an onclick event that calls some javascript to highlight the row, or in the case of the checkbox in the header, to select/deselect all checkboxes. I need to call the "SaveCheckBoxState" method from the javascript used by the customcontrol, or I need to find a way to modify viewstate from javascript and perform the same action as "SaveCheckBoxState".
I've tried adding the "SaveCheckBoxState" to the onclick event declaration in the checkboxes, but when run, it simply tells me that the method is undefined. It doesn't exist in the parent page, and I don't think I should have to make an event for the parent page to pass the click to. It seems to me this should be all self contained within the custom control. Does anyone know how I can acheive this? Here is the code for the gridview OnPreRender event where the onclick event of the checkbox is set:
protected override void OnPreRender(EventArgs e)
{
// Do as usual
base.OnPreRender(e);
// Adjust each data row
foreach (GridViewRow r in Rows)
{
// Get the appropriate style object for the row
TableItemStyle style = GetRowStyleFromState(r.RowState);
// Retrieve the reference to the checkbox
CheckBox cb = (CheckBox)r.FindControl(InputCheckBoxField.CheckBoxID);
// Build the ID of the checkbox in the header
string headerCheckBoxID = String.Format(CheckBoxColumHeaderID, ClientID);
// Add script code to enable selection
cb.Attributes["onclick"] = String.Format("ApplyStyle(this, '{0}', '{1}', '{2}')",
SelectedRowStyle.CssClass,
style.CssClass,
headerCheckBoxID);
// Update the style of the checkbox if checked
if (cb.Checked)
{
r.BackColor = SelectedRowStyle.BackColor;
r.ForeColor = SelectedRowStyle.ForeColor;
r.Font.Bold = SelectedRowStyle.Font.Bold;
}
else
{
r.BackColor = style.BackColor;
r.ForeColor = style.ForeColor;
r.Font.Bold = style.Font.Bold;
}
}
}
View 1 Replies
May 11, 2010
I am creating a custom 'control' which is simply made of two html inputs [type=text] but can't figure out how the validation will work on the view end.
I want to treat these 2 inner controls as asingle control so when a error is added to modelstate both of these inputs are highlighted in the view and a single validation message is shown.
View 3 Replies
Jan 11, 2010
I'm having problems with getting my custom dataannotations to work, I'm trying to add a validation-attribute that validates that the UsergroupName for a Customer (CustomerID) is unique.
[Code]....
the IsValid should return false if the "count >0". How do I fix this one so it works. GetUsergroups() returns IQueryable<Usergroup>.
View 8 Replies
Jun 30, 2010
protected void cusCustom_ServerValidate(object sender, ServerValidateEventArgs e)
{
if(e.Value.Length == 8)
.IsValid = true;
else
e.IsValid = false;
ge code
<asp:CustomValidator runat="server" id="cusCustom" controltovalidate="txtoedate" onservervalidate="cusCustom_ServerValidate" errormessage="The text must be exactly 8 characters long!" />
View 3 Replies
Dec 23, 2010
I am new to asp.net and I have a problem. When the users insert in a editor for a decimal field something other than numbers, they get an error "Field name" is not a number. But I don't want them to receive this message I want them to receive another message. I have no problem with this with required and range validators. Is there any way for me to do this?
I am not refering necessarily to changing the culture just displaying another message.
View 6 Replies
Apr 3, 2010
I am creating a system in visual web developer. I want to use the custom validation to validate an email address.I am using Visual basic to do it in.so far i have
Dim ampposition As Integer
Dim dotposition As Integer
For i = 1 To Len(txtemail.Text)
Next
As i want to use a for loop to validate the email
View 4 Replies
Jul 13, 2010
I need to fire some custom JavaScript validation and then submit my ASP.NET using JavaScript.How do I submit the form using JavaScript?
View 3 Replies