473,779 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to set innerHTML of an asp Label control

I want to use a asp Label control (or a <div runat=server> element) in a
template column of a datagrid. In the code behind in the grid's
ItemDataBound event I need to dynamically set the innerHTML of this control
with data and line breaks (<br>).

The problem is that while working in the code behind, I don't see any
properties for this control where I can set innerHTML, only text.

Any good ideas?

--
mo*******@nospa m.com
Nov 18 '05 #1
1 11446
Hi Moondaddy,

As for the problem how to set the innerHTML of a ASP Label Control. I think
you can directly use its "Text" property. For example:

if we have a Label control as below:
<asp:Label id="lblHtml" runat="server"> </asp:Label>

Then in code behind, we can set its innerHtml like this:
lblHtml.Text = "<table width='200'
border='1'><tr> <td>content</td></tr></table>";

So the only thing we need to do is just retrieve the certain Label Control
from the certain cell in the DataGrid in
its ItemDataBound event and then use its "Text" property to set the
innerHtml. Please have a try to see whether this helps. Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #2

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

Similar topics

4
2063
by: lendle | last post by:
I have defined onclick event handler within the innerHTML property as following: var testButton1=oWin.document.createElement("LABEL"); testButton1.innerHTML="<input type='button' value='xx' onclick=\"alert('123')\">"; oLabel.appendChild(testButton1); the oLabel has already been append to document.body
3
2952
by: nLella | last post by:
Hello, Is there any way where, from server side, I can access the innerHTML value of a control (Hyperlink/Label) which is modified at the client side ? I wish to read the changed InnerHtml on the server side. Can I really do this? any help will be appretiated. -- Thanks
14
6092
by: nickdevx | last post by:
Without knowing "html before" and "html after" can anyone fathom any reason why the following code crashes IE but if I add <br/> after ANY <input> tags it doesn't? ****************************************************** HTML = "html before"; HTML += "\ <label for='m-bx'>X:</label><input type='text' id='m-bx'/>\ <label for='m-by'>Y:</label><input type='text' id='m-by'/>\ <label for='m-bw'>Width:</label><input type='text' id='m-bw'/>\
1
366
by: moondaddy | last post by:
I want to use a asp Label control (or a <div runat=server> element) in a template column of a datagrid. In the code behind in the grid's ItemDataBound event I need to dynamically set the innerHTML of this control with data and line breaks (<br>). The problem is that while working in the code behind, I don't see any properties for this control where I can set innerHTML, only text. Any good ideas?
6
6935
by: Joe | last post by:
I know that the Literal control will not render a <span> tag so I can not format its text. Other than this, what is the difference betwen the Literal control and the LiteralControl Control? How about a LiteralControl and a Label? Other than the lack of being able to format the Literal control's text, I don't see much of a difference in the documentation. TIA, --
7
1757
by: MaryA | last post by:
Let me preface this with the fact that I am a newbie to HTML, XML and Javascript. Having said that, let me explain my dilemma: I am having a difficult time getting innerHTML to consistently return the entire HTML string when a <p> is part of the text. It somehow throws everything off. I am trying to store exam questions in an Oracle Database as XML. The XML I started with looked like this: <aicpcu id="XMLTEXT"><stem id="STEM">This...
7
2608
by: Nez | last post by:
Help needed! Hello, I have looked everywhere for a solution to my problem and this is pretty much my last resource. I have created a table in a span with the innerhtml command in my code behind. In this table I have created textbox html input fields. Now I need to allow the user to change the value in the textfield, and compare it to the old value I have stored in a cookie. Problem is, because the textfield was created in the code...
4
2917
by: poojak | last post by:
I have write two different js function in a external file. one function write a table (I used innerHTML for this.) and another function is for showing/ hideing some rows depending on radio button selection. Both of these function works properly when used in HTML file, but when I use same showhide function in a table which is created by Javascript that function doesn't work at all. I am copying both JS functions here also, If someone can solve...
2
3737
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm in a gridview edit row that has a DropDownList in one column and a status Label in the 2nd column. When i changed the value in the dropdownlist, there's a client-side javascirpt function that runs and successfully populates label in the 2nd column. Everything is fine at this point and working the way it should. i do a getElementById to get the status label and then i set its innerHTML and again it works fine.
0
9633
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10305
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8959
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.