473,324 Members | 2,511 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,324 software developers and data experts.

innerHTML not working

Hello,

I am trying to get the innerHTML method to work but I am not getting
any output.

Here is my code:

(Code behind)
Dim display as New HtmlGenericControl
Dim strResultsHolder As String

strResultsHolder = "<table><tr><td>Hello World</td></tr></table>"
display.InnerHtml = strResultsHolder

(The HTML section of my form)

<div id=display runat=server> </div>

(end HTML section)

Can someone please tell me if this is correct? I am wondering how I
specifically reference the div id (display).

I have given it a HtmlGenericControl datatype in the code behind but is
that good enough to point it to the div id of the same name in the
form?

In all of the samples I can google not one has specifically referenced
the HtmlGenerciControl class in the code. They all say to do it but
don't actually show it being done.

Can someone say if this is correct or how to do it?

Thanks

Nov 19 '05 #1
8 7502
Remove "New"
Don't instantiate the control.
Let ASP.NET instantiate it and match it with the control of the same name in
your HTML.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"sling blade" <sc******@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hello,

I am trying to get the innerHTML method to work but I am not getting
any output.

Here is my code:

(Code behind)
Dim display as New HtmlGenericControl
Dim strResultsHolder As String

strResultsHolder = "<table><tr><td>Hello World</td></tr></table>"
display.InnerHtml = strResultsHolder

(The HTML section of my form)

<div id=display runat=server> </div>

(end HTML section)

Can someone please tell me if this is correct? I am wondering how I
specifically reference the div id (display).

I have given it a HtmlGenericControl datatype in the code behind but is
that good enough to point it to the div id of the same name in the
form?

In all of the samples I can google not one has specifically referenced
the HtmlGenerciControl class in the code. They all say to do it but
don't actually show it being done.

Can someone say if this is correct or how to do it?

Thanks

Nov 19 '05 #2
I tried that and I get this error
Object reference not set to an instance of an object.

at this text is highlighted in red:
display.InnerHtml = strResultsHolder
When I instantiate display with the New keyword I don't get the error
but still no table.

Any ideas?

Nov 19 '05 #3
Where are you declaring it?
It should be declared as "protected" at the top of your class along with the
other standard controls such as labels, buttons, etc.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"sling blade" <sc******@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I tried that and I get this error
Object reference not set to an instance of an object.

at this text is highlighted in red:
display.InnerHtml = strResultsHolder
When I instantiate display with the New keyword I don't get the error
but still no table.

Any ideas?

Nov 19 '05 #4
You also need to declare it as "protected" instead of "dim"

so

protected display as HtmlControl ought to do the tric;

the aspx page inherits from the codebehind and "protected" allows
sub-classes to access the property.. I believe that "dim" does private by
default...which is too limiting in this case

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"sling blade" <sc******@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I tried that and I get this error
Object reference not set to an instance of an object.

at this text is highlighted in red:
display.InnerHtml = strResultsHolder
When I instantiate display with the New keyword I don't get the error
but still no table.

Any ideas?

Nov 19 '05 #5
By the way Karl the link to My ASP.Net tutorials doesn't seem to be
working (at least I can't get to it right now anyway)

Nov 19 '05 #6
Great! That did it. And thanks for the explanation too (that was my
next question).

Nov 19 '05 #7
Yeah u have to declare it as:-

Protected WithEvents display As
System.Web.UI.HtmlControls.HtmlGenericControl

Patrick

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #8
thx but seems ok to me...maybe just a hickup :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"sling blade" <sc******@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
By the way Karl the link to My ASP.Net tutorials doesn't seem to be
working (at least I can't get to it right now anyway)

Nov 19 '05 #9

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

Similar topics

4
by: John | last post by:
In my script <script language="javascript"> function AddItinerary() { var newRow; var newCell1,newCell2,newCell3,newCell4,newCell5,newCell6; newRow = document.createElement("tr"); newCell1...
12
by: Epetruk | last post by:
Hi all, I want a page where the contents of a table cell are replaced with an image when the mouse moves over the cell, and the text is restored when the mouse moves out. Here's the html for the...
4
by: Anders Nielsen | last post by:
Hi :-) I'm currently working with innerHTML , but it is giving me some problems with " and '. Basically (there is also some ASP involved), my problem looks like this: I would like to,...
40
by: Geoff Cox | last post by:
Hello, I am still having problems - apologies if the answer is in previous postings! I now have, in the header, <sctipt> var myimages=new Array();
16
by: Joel Byrd | last post by:
I am having this ridiculous problem of trying to set the innerHTML of a div node. It works in all other browsers, but internet explorer is giving me an "Unknown runtime error". This is actually...
4
by: windandwaves | last post by:
Hi Folk Can you please have a look at http://www.friars.co.nz/map.php and let me know if the map is working on IE6 (just do a simple search). Unfortunately, I do not have IE6 anymore and so I...
8
by: Pratik Patel | last post by:
Hello, I used innerHTML to assign HTML content. but in my HTML page content have also some javascript function and it will run when page load. bu when HTML code assgin thru innerHTML then this...
1
by: Tarik Monem | last post by:
I have been able to successfully retrieve data from an xml file, where the data has been massaged a little bit, to create a table to be retrieved and it is displayed via a document.writeln within a...
2
by: sabrinakr | last post by:
Hi All, I have spent a long time on this and still cant figure out whats wrong. I have recently started with javscript and my question is as follows: The page works fine but if the User...
3
by: mark roldan | last post by:
Hi, this is a code for form verification... I added the function results() then the entire script is now not working. Need help... *note that if I omit the results() function, other functional parts...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.