Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET WebForms
for example:
1.
linkBtnName.Attributes.Add("onmouseover","document.getElementById('someId').src='asdf.gif'"); 
 
2.
 e.Row.Attributes.Add("OnDblClick", "__doPostBack('GridView1','Select$" + e.Row.RowIndex + "')");
 
It's a js expression,but I am so puzzled! So I want a introduction about this. See the 2 up there is a Select$, I don't know where its come. Because I never see one to use like that and I don't have an introduction about it. Please give information about this topic.
 
___________________________________________________________________
I mean I don't know how to use object's attributes.add() method.
for example:button.attributes.add()
textbox.attributes.add()
Posted 7-Nov-10 20:39pm
Edited 8-Nov-10 18:05pm
v5
Comments
shakil0304003 at 8-Nov-10 4:30am
   
Not clear!!!
Baji Jabbar at 8-Nov-10 5:06am
   
Yes , its not clear. Some more detail will be helpful. What you actually want ? :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi Angel,
Server controls like Button and label have properties (attributes) like runat, id, name, style.
Ex : <asp:label id="lbltest" runat="server" style="display:block" text="Test" xmlns:asp="#unknown" />
here, id, runat, style and Text are the attribute, which means that attributes of the controls can be set at design time or runtime.
 
I hope this would help you.
 
Regards,
Jitendra Zaa
  Permalink  
Comments
AngelLoose at 9-Nov-10 20:16pm
   
thanks
AngelLoose at 9-Nov-10 20:16pm
   
I see.But I want ask you how to use it in .cs document and how to write .Such as made a mouseover event.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can use the attributes in several different ways:
 
1. When you assign an attribute to a "runat=server" control, it will render the attribute as an attribute of the underlying HTML tag, and, as you know, it will be a JavaScript expression description.
 
2. You can assign an attribute on the server side and later get this attribute on the server side inside a different procedure.
Say, you assign and attribute during the LayoutCreated event and get it back on ItemDataBound event. I found it very useful when working with databound controls
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 480
1 Maciej Los 290
2 Richard MacCutchan 225
3 BillWoodruff 185
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,764
1 Sergey Alexandrovich Kryukov 7,437
2 DamithSL 5,639
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 9 Nov 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100