document.getElementById("ReportViewerID") returns null

G

Guest

I have a ReportViewer control (from reporting service) in one asp.net web
page. The document.getElementById("ReportViewerID") always returns a null.
Other controls in the pages seems OK and the function can return the right
object. Could anyone help me out?

Thanks,
 
E

Erik Funkenbusch

I have a ReportViewer control (from reporting service) in one asp.net web
page. The document.getElementById("ReportViewerID") always returns a null.
Other controls in the pages seems OK and the function can return the right
object. Could anyone help me out?

Thanks,

It's pretty simple. If it's returning null, then that ID doesn't exist.
Check the generated HTML and search for that ID, you aren't going to find
it.
 
G

Guest

I copied the ID to the function in the same aspx file. I am 100% sure it is
there.
 
G

Guest

Your ID for your report viewer is "ReportViewerID"? Double check that.
Also, if you are using master pages and content pages, the content
placeholder ID is prepended to all controls contained in it. That means,
when the page is rendered to the client, the actual ID for the report viewer
would be something like "ContentPlaceholder00_ReportViewerID". Definitely
grab a client-side debugging tool like Fiddler or the Explorer developer
toolbar and look at the HTML on the client side. You may be surprised.
 
G

Guest

William, thank you.

You are right. The actual ID has been changed to
"ReportFrameReportViewerID". Plus, these two tools are very good tools.

Thanks again.
 
L

Laurent Bugnion

Hi,
William, thank you.

You are right. The actual ID has been changed to
"ReportFrameReportViewerID". Plus, these two tools are very good tools.

Thanks again.

There is no guarantee that it will always be ReportFrameReportViewerID
so better not use that as a constant. Use your control's ClientID
instead of it's ID. ClientID is the string which will be sent to the client.

HTH,
Laurent
 
E

Erik Funkenbusch

I copied the ID to the function in the same aspx file. I am 100% sure it is
there.

I guarantee you, it's not. Just check the generated HTML like I said.
Don't be stubborn.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top