Click here to Skip to main content
12,691,097 members (32,526 online)
Rate this:
 
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
Updated 8-Nov-10 18:05pm
v5
Comments
shakil0304003 8-Nov-10 4:30am
   
Not clear!!!
Baji Jabbar 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 9-Nov-10 20:16pm
   
thanks
AngelLoose 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170117.1 | Last Updated 9 Nov 2010
Copyright © CodeProject, 1999-2017
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