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

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

Is it ok to make my own element attributes?

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :ASP.Net
I want to make up some new attributes for elements like <div> and <a>. Those new attributes will be used to store data to be used by click handler jquery code.  Is that ok to do?  Is it supported by older browsers?   Testing on IE8 and Chrome, I am able to use jquery to store and recall in these made up attributes of a <DIV>element. ( I tried to use expression web super preview to test the code.  But apparantly, super preview does not run javascript. )thanks, <div id="div1" MadeUpAttr="abc"></div>     <script type="text/javascript">      $(document).ready(function ()      {        var s1 = $('#div1').attr('MadeUpAttr');        alert('MadeUpAttr: ' + s1);         $('#div1').attr('MadeUpAttr', 'efg');        var s2 = $('#div1').attr('MadeUpAttr');        alert('MadeUpAttr: ' + s2);      });    </script>  

View Complete Post

More Related Resource Links

C++ Attributes: Make COM Programming a Breeze with New Feature in Visual Studio .NET


C++ attributes in Visual Studio .NET are used to generate C++ code through attribute providers. Attribute providers generate code for COM classes, and the code is injected by the C++ compiler at compile time. This has the effect of reducing the amount of code that you need to write. In addition, with C++ attributes you no longer need to maintain separate IDL and RGS files, which makes project management simpler. This article explains C++ attributes, the process used by the attribute provider to generate code, and the code that is automatically generated. It also covers how attributes affect the registration process, how attributes can be used to generate code module entry points, and how connection points can be implemented using C++ attributes. Also explained is how these features contribute to the Unified Event Model for the .NET platform.

Richard Grimes

MSDN Magazine April 2001

XmlSerializer - how to define class to not generate attributes in root element?

Hi! I have simple class that I serialize to xml file: <?xml version="1.0" encoding="utf-8"?> <MyRootElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Area="East">   <Products>     <SalesProduct Taxable="true">       <Name>Sofa</Name>     </SalesProduct>     <Product>       <Name>Television</Name>     </Product>   </Products> </MyRootElement> I don`t want have in xml file attributes xmlns:xsi and xmlns:xsd. How can I define class to not have these two attributes in xml file? I tried use XmlRoot attribute but there is no control for these two attributes. They are always generated. Regards

Schema :relatioship expected & constant/fixed element cannot have attributes

I try to bullkload data from xml file to SQL database ,but I cannot figure out the problem.Please anyone help me .I'd really appreciate. the XML file :  <?xml version="1.0" encoding="UTF-8"?> <root>        <!-- ????? -->        <common>               <!-- UploadDataCenterID???????????????? -->               <UploadDataCenterID>XXXXXX</UploadDataCenterID>               <CreateTime>YYYY-MM-DD HH:MM:SS</CreateTime>        </common>        <data>                 <BuildGroup id="XXXXXXXXXX">                        <BuildGroupBaseInfo operation="N|U">                             <F_BuildGroupName>?????</F_BuildGroupName>                             <F_GroupAliasName>???????</F_GroupAliasName>                             <F_GroupDesc><![CDATA[?????]]></F_GroupDesc>                      </BuildGroupBaseInfo>                      <BuildGroupRelaInfo operation="N|U">                             <F_BuildID>XXXXXXXXXX</F_BuildID>                      </BuildGroupRelaInfo>               </BuildGroup>        </data> </root> then the XSD :<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xs

how to make sure for not empty XML element?

Msg 2298, Level 16, State 1, Line 1 Attribute "use" is not valid in this schema context whats wrong below, CREATE XML SCHEMA COLLECTION TestSchema5 AS' <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Address"> <xs:complexType> <xs:sequence> <xs:element name="Name" type="xs:string" use = "required"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>'

Can XmlSerializer add attributes to an element?

I'm using XmlSerializer to serialise a c# object into XML.public class Letter{        [XmlElement]        public String AccountNumber { get; set; }}which gives:<Letter><AccountNumber>12345678</AccountNumber></Letter>What I'd like to be able to do is to add a flag as an attribute to say if the particular data element is encrypted, so the XML comes out as:<Letter> <AccountNumber encrypted="true">=S2Hgd3$eDF</AccountNumber> </Letter>Is it possible to add this encrypted flag easily using the XmlSerializer? Thanks for any advice!

XML file - write attributes in root element


i have to write the following XML file using .net 2005.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

- <IMPORTFILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ARC_Carrier_Import.xsd">

the constant/fixed element cannot have attributes sqlxml bulkload error


My xml schema fails in getting attributes from 'empty' element... using sql:is-constant="1" disables reading attributes and by not using constant for element, error comes back with define relation... element is only a header for the attributes...

part of the xml:

<orderitem id="124810">


<name><![CDATA[Jac Digilabel folie tra glos]]></name>


<attribute name="ALGEMEEN_KLEUR"><![CDATA[Transparant]]></attribute>

<attribute name="ALGEMEEN_FORMAAT"><![CDATA[320x460]]></attribute>

<attribute name="ALGEMEEN_GEWICHT"><![CDATA[110]]></attribute>

UpdatePanel is not a known element - message when upgrading to 1.0 ajax


It worked on one of my old pages.  I change the web.config, renamed all the <asp.

On some aspx page it doesn't recognize the updatepanel.  It only does on one page.  If I create a new aspx page with a different name - then it works.

Should I just create a new web project ajax - then copy all my code into there?  Or is there a way to get those old pages to recognize the new ajax controls?

Beginner: this doesn't make sense to me


Do you need and "empty" script tag in the head to run scripts that are in the body?  Also, can you run JQuery scripts if they're in the <head> tag?  The first sample only works if the JQuery script is in the form (and body) tag, not in the head - even if I add $(document).ready(function() { });

This works

<head runat="server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" />
<script type="text/javascript">
<form id="form1" runat="server">
<a href="">Here is a link</a>
<script type="text/javascript">
$('a').click(function () {
alert("you clicked me!");


This doesn't work.  Notice I removed the second <script> tag from the head

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="serve

how to make a dropdownlist looks like google search box


dear all...

any idea how to do that ?

Thnx in advance

Need Syntax To Make Results of LINQ Union Return Non-Generic Type



I have the below SQL which works just fine:

SELECT     Message, CreateDate, AccountId, AlertTypeId
FROM       dbo.Alerts
SELECT     TOP (100) PERCENT Status, CreateDate, AccountId,
                          (SELECT     10 AS Expr1) AS AlertTypeId
FROM         dbo.StatusUpdates
WHERE AccountId = PassedInParameter

I have been going about trying to convert the above into a LINQ method and am having problems with return types.
As the above SQL illustrates, I am querying two distinct LINQ tables - Alerts and StatusUpdates -
and then attempting to perform a Union on them. In order to do the union in LINQ, I have to have agreeing types. So, I
am using "var" to make the results of "alerts" and "updates" generic before the union.  

public IList GetStatusUpdatesAsAlertsByAccountId<T>(Int32 accountId)
            using (WorkbookDataContext dc = _conn.GetCont

Unable to make connection to database?


Hy guys. I try to connect my database for so long so i wrote two type of codes. Let's discuse first on.

I have database called PhoneDirectory.

It have only one table named Residents.

I have button wiht ID="Button1".

I want when i click this button to see all of my residents. 

I want to see the result in DetailsView and to be able to edin, delete and add new resident.

First try with SqlDataSource so i wrote this:

<asp:SqlDataSource ID="Resident Details" runat="server" ProviderName="System.Data.SqlClient" ConnectionStrings="<%$ ConnectionStrings:ThisIsTheConnection%>" 
              SelectCommand = "SELECT * FROM Resident "

get value from xml element



i have this xml

<Field Name="Users_wff_AU" Type="FIELD_TYPE_STRING" MultiValue="True">
<Value No="1">xyz</Value>
<Value No="2">abcl</Value>
<Value No="3">xcc</Value>

i want to get the  xcc in string variable

Dim strwfUser As String = xNode.Item("Value").InnerText

how to make a css style background image be linked to an image in the resource file


hey guy, i need help in a very troubling matter. I want to make a textbox with a specific style, within this style a set of images as background parts, how can i attach these images to the custom control as whenever i take the .dll file and add it to the toolbar the images do not appear. So i tried to make them as resource files and their property as embedded in .resx file, so how to make the css style background image url to be linked to any of those image.

thanks in advance

Could not find default endpoint element that references contract 'CurrencyProxy.CurrencyServiceSoap



I created 2 projects in my solution:

  1. Classic asp.net web service (asmx)
  2. Class library project which references service
  3. web site project which references class library project
  4. Windows app project which references service.

Both projects were created in 3.5 framework and in Visual Studio 2008 Beta 2.

I added web service reference to Class library project. When it asked for namespace I typed "CurrencyProxy". Projects build ok, but when I run web app, Class library throws an error: Could not find default endpoint element that references contract 'CurrencyProxy.CurrencyServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

I believe it has something to do with app.config in Class library project. Here is part from app.config:

<binding name="CurrencyServiceSoap" closeTimeout=

Make sure that the class defined in this code file matches the 'inherits' attribute, and that it e


Here is the page directive for the page that throws the error:

@ Page language="c#" Inherits="University.AspNet.Index" CodeFile="Index.aspx.cs" %>

The code behind file Index.aspx.cs starts like this:

using University.Framework.UI;

namespace University.AspNet

public partial class Index : University.Framework.UI.HomePage

The code behind is extending this HomePage class, which is in turn an extenstion of another class University.Framework.UI.Page, which extends the System.Web.UI.Page class.

Am I misusing the I

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