473,382 Members | 1,665 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

change attribute in html elements

How can I change attribute in html elements from my aspx.cs page?

For example if I want to change the src-attribute in an iframe.

//Linus
Nov 17 '05 #1
2 3477
when i want to change the attribute of a htmlcontrol in c#, i use:

HtmlControl.Attributes["attributename"] = "attributevalue"

eg: oHtmlTableCell.Attributes["class"] = "headercell";

hope this helps you.!
"Linus Martinsson" <Li**************@swipnet.se> wrote in message
news:ep**************@TK2MSFTNGP10.phx.gbl...
How can I change attribute in html elements from my aspx.cs page?

For example if I want to change the src-attribute in an iframe.

//Linus

Nov 17 '05 #2
Make the html object into a server side control.

1) Add and id="myobject" and runat="server" attributes to the object in the
html code:

<iframe id="MyIframe" runat="server"></iframe>

2) Dim the object in your codebehind page as a
System.Web.UI.HtmlControls.HtmlGenericControl:

Protected MyIframe As System.Web.UI.HtmlControls.HtmlGenericControl

3) Now you may add attibutes dynamically as suzy suggests.

MyIframe.Attributes.Add("[Attribute Name]", "[Attribute Value]")

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Linus Martinsson" <Li**************@swipnet.se> wrote in message
news:ep**************@TK2MSFTNGP10.phx.gbl...
How can I change attribute in html elements from my aspx.cs page?

For example if I want to change the src-attribute in an iframe.

//Linus

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: aragon | last post by:
Hi all, is it legal to use a fully-numeric string as "name" attribute for the <select> tag in the XHTML standard? E.g.: <form action="action.php" method="get"> <select name="12345"> <option...
3
by: pantagruel | last post by:
The following does not work in firefox: <script defer="defer"> var x=document.getElementsByName("repositoryNamespace") alert(x.length + " elements!")
6
by: Joe | last post by:
Hello All: Does anyone know the difference between the name and id attributes in an Html control? I noticed on PostBack that I can not retrieve the Request.Form("id_value") but I can retrieve...
15
by: Encapsulin | last post by:
Hello everybody. I'm trying to change src of quicktime embedded object with javascript: <html><body> <script language="JavaScript"> function Exchange() { document.qtvr.src = "sample2.pano";...
4
by: Mel | last post by:
how can i change disabled background on all form elements ?
7
by: Tim Rogers | last post by:
Hi folks, this is a resolution-detect script that I used on a site. As you can see it is designed to detect when the screen resolution falls below a certain level then load an alternative style...
6
by: mayurkoul2002 | last post by:
hello there..... i have a problem here...........i want to assign ID attribute dynamically to the html tags......and i need a function for tht....can anybody help me out in tht
11
by: Jasbird | last post by:
Has the name attribute deprecated? I ask this because ASP.NET 2 warns me against using it, says that it has been deprecated and doesn't use it (on the client) when creating a radio button list....
4
by: Ross Presser | last post by:
I'm feeling very stupid about this ... pdf2html (http://pdf2html.sourceforge.net) is an app that reads a PDF and can generate HTML or XML; in my case I'm using the XML. The PDF I'm working with...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.