.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

W3C Validation for XHTML 1.0 Strict with Custom Attributes (Javascript "triggers")?

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

I've searched high and low on this issue, finding so-called "solutions" involving custom DTD's, using alternate valid attributes in an element to substitute for the invalid attributes, to doing nothing at all about the issue. I want to see what the experts here think.

The problem is that I'm using a 3rd-party control that adds several custom attributes (to act as javascript triggers) to a <td> tag (and one for a <div> tag also). So whenever I try to validate my page against the W3C's validator for XHTML 1.0 Strict, I get errors. Having the 3rd-party control supplier fix their controls is pretty much out of the question (very slow to respond, if ever), so it's something I'll need to deal with myself. The rest of the pages on my site all validate, and the control in question is the very last obstacle to complete validation. Not validating isn't an option I'm ready to consider.

So, any ideas?


View Complete Post

More Related Resource Links

Validation is not working in Custom List Form using JavaScript ddwrt:GenFireServerEvent()

Hii am creating custom New form for a list using sharepoint designer. i have added the below button for sumbit<input name="Submit1" type="submit" value="Submit" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={http://myserver/Lists/VTest/AllItems.aspx}')}" />                <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp;                                    </xsl:text><input name="Submit2" type="submit" value="Cancel" onclick="javascript: {ddwrt:GenFireServerEvent('__redirect={http://myserver/Lists/VTest/AllItems.aspx}')}" />the problem is the validation is not working properly. it submits the page without entering values for the required fields.particularly the validation is not working for DateFields.let me know what is the problem here. is it a Bug?muthu

Custom Attributes + Reflection


I recently started messing around with custom attributes and reflection. In my code below GetCustomAttributes never return a list (it should return atleast one):

Am i defining the custom attrib wrong?

public class GOrder:IOrder
        public string CertProductIDString { get; set; }

        public string GetRESTParams()
            string data = string.Empty;
                System.Reflection.MemberInfo inf = this.GetType();
                object[] attributes;
                attributes =  inf.GetCustomAttributes(typeof(RESTParamAttrib), true);
                foreach (Object attribute in attributes)
                    RESTParamAttrib attrib = (RESTParamAttrib)attribute;
                    data = data + string.Format("\nData: {0}", attrib.Param);

            catch (Exception ex)

                throw ex;

            return data;

    public class RESTParamAttrib:System.Attribute
        public RESTParamAttrib (string param)
            Param = param;

        public string

Basic Instincts: Designing With Custom Attributes


One of the most powerful aspects of the Microsoft® . NET Framework is its support for attributes. Attribute-based programming is extremely powerful because it adds a declarative dimension to designing and writing software.

Ted Pattison

MSDN Magazine May 2005

decimal value validation and round off by javascript

The article decimal value validation and round off by javascript was added by hiral.hapani on Wednesday, June 02, 2010.

Hi All, I have createdone javascript by which you canvalidate a decimal value of any textbox for which you want. By thisjavascriptwecan bind user to enter only digits in textbox. and when he will enter any decimal value javascript will do round off it

Rejected by custom validation error & ItemAdding



I believe this topic was discussed before in this forum, but I couldn't find it using the exact error I receive: "operation for file.doc was rejected by custom validation on the server"

When I try to add a new word document to my doc library, Word displays this error instead of my custom error message. I set properties.Cancel=true in ItemAdding of my EventHandler, because my validation fails. 

Is there any way to display user properties.ErrorMessage instead of this generic error message?


Asp.net Javascript Validation dd/mm/yyyy format


Hi experts,

 I am trying to validate two textbox (fromdate,todate)

should alert a message when Fromdate is more than Todate

I could find only mm/dd/yyyy format in most of google search.

please give me a script or assist how to do this.



Html.RenderPartial appears to be stripping Model of custom attributes



I have implemented a custom ModelMetadataProvider so that I can decorate my view models with some custom attributes and everything was working fine until I made use of a Partial View.

The following code in my view works fine: -

<%: Html.DisplayFor(x => x.Results) %>

Results is a List which renders a custom display template and is also decorated with a custom attribute.  Using breakpoints, after the above line and prior to the code within the custom display template, the overridden CreateMetadata method in my custom ModelMetadataProvider is invoked.  If I look at the attributes collection parameter I can see that it does contain my custom attribute thus everything working as expected.

However, if I replace the above with the following line of code in my view then it breaks: -

<% Html.RenderPartial("ApplicationSearchResults", Model.Results, new ViewDataDictionary()); %>

All the Partial View contains is: -

<%: Html.DisplayFor(x => x) %>

Again using breakpoints, after the above line and prior to the code within the custom display template, the overridden CreateMetadata method in my custom ModelMetadataProvider is invoked.  But this time if I look at the attributes collection parameter my custom attribute is not there.

Any idea

Cannot set custom attributes on mobile controls in this page



I am beginner at mobile Pages with ASP.NET. And i want to make an application with contains  a few TextBox that have different size.

it's my sample code here:

<%@Page Inherits= "System.Web.UI.MobileControls.MobilePage" Language= "C# " %>
<%@ Register TagPrefix= "Mobile" Namespace= "System.Web.UI.MobileControls " Assembly= "System.Web.Mobile" %>
<Mobile:Form runat="server" id="form1" Paginate="true" >
<Mobile:Panel Paginate="True" runat=&

Custom Validation Attribute is not called by validation mechanism.

Hello everyone I have create custom validation attribute and assign it to class level validation. Unfortunately, it is not called. I try every way that it think it could be solve the problem. However, it take me for hours and I can't find the attribute is not called by validation mechanism.For illustrate you I put the following code.Attribute[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public sealed class BooleanDependencyAttribute : ValidationAttribute { private const string _defaultErrorMessage = "?????????{0}"; private readonly object _typeId = new object(); public string DependencyPropertyName { get; private set; } public string DependentPropertyName { get; private set; } public BooleanDependencyAttribute(string dependencyPropertyName, string dependentPropertyName) : base(_defaultErrorMessage) { DependencyPropertyName = dependencyPropertyName; DependentPropertyName = dependentPropertyName; } public override object TypeId { get { return _typeId; } } public override string FormatErrorMessage(string name) { return String.Format(CultureInfo.CurrentUICulture, ErrorMessageString,name); } public override bool

Access Model Validation inside Custom Model Binder.

Hello,Is it possible, inside a Custom Model Binder, to fire "something" that "says" the value is invalid so it gets handled by validation part?Basically, I am getting an exception when the value for the property is invalid.Thank You,Miguel

custom model validation

 Hi all, I am trying to wrap my head around a practical real world scenario where the out-of-the-box model validation framework in MVC2 poses some challenges. Consider the following model classes:     public class Organization    {        public int ID { get; set; }         [Required(ErrorMessage = "Work Address is a required field.")]        [DisplayName("Work Address")]        public Address WorkAddress { get; set; }         [DisplayName("Home Address")]        public Address HomeAddress { get; set; }     }     public class Address    {        [DataType(DataType.Text)]        [DisplayName("Address 1")]        [StringLength(50)]        [Required(ErrorMessage = "Address Line 1 is a required field.")]        public string Address1 { get; set; }         [DataType(DataType.Text)] &n

Javascript FromDate to Date Validation Help!

Hi,I want to check fromdate and todate in dd/mm/yyyy.The code below mentioned works perfect for single textbox(fromdate) ,but when tried to do for todate(textbox) it doesnot work properly.From Date Should not be greater than ToDate.Please Help.Below is the code:<html><head><title>Date Example</title><script type="text/javascript">    function isValidDate(sText) {        var reDate = /(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20\d{2})/;        return reDate.test(sText);    }    function validate() {        var oInput1 = document.getElementById("txt1");        if (isValidDate(oInput1.value)) {            alert("Valid");        } else {            alert("Invalid!");        }    }</script></head><body>    <P>Date: <input type="

How to include a javascript file in a custom action?

I need to call a custom javascript function from a ribbon button, how do I include the javascript file within the custom action solution in order that it will be properly referenced by the html output? I am not allowed to define a custom masterpage at this point. So what can I do?   Thanks, Stephan  

Custom validation attribute that compare 2 valaues

I want to create Custom validation attribute  that compare 2 valaues i wnat to get the two vlaue   in side the validator together sucha that i have check  2 conditions 1)if the values of the two fieds are 0 then no need to do any comparison else value 1 should be less than value 2 MVC2  

how should i use custom validation in asp.net....

1)plz help me in doing the custom validation in asp.net.... 2)i also use java script also in custom validation.....3)provide me some examples also......

Updating gridview attributes from javascript

Hello,   I have been trying to use a custom attribute in my gridview to pass a comma delimited list of guids between my server-side and client side code.  Normally I would just use a hidden-field to do this, but I have to add a hidden-field into a row in my gridview to use one.  Since I need access to the updated value from javascript before my grid is rendered on postback, I can't use a control that is buried inside a row.  So instead, i was trying to add an attribute to the gridview and having the javascript update that value.   Here is the private property defined in my extended gridview class:  private List<Guid> _selectedValues { get { List<Guid> myList = new List<Guid>(); if (this.SelectionType != SOMgridviewSelectionType.None) { if (ViewState["SelectedValues"] != null) { return (List<Guid>)ViewState["SelectedValues"]; } } return myList; } set { if (this.SelectionType != SOMgridviewSelectionType.None) { if (string.IsNullOrEmpty(this.Attributes["hiddenSelectedValues&q

javascript for field validation on a textbox...

I'm looking at doing the validation for the email in javascript since we have asp.net 1.1. I can get it to just alert fine, but once I add the return validation it doesn't fire. Me.ImageButton2.Attributes.Add("onclick", "return validation(this);") <script language="JavaScript"> <!-- function validation () { var test=""; test = document.ticketForm.emailAddress.value; if (test == "xyz") { alert(test); return false; // validation failed } --> </script>
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend