Home All Groups Group Topic Archive Search About

document.getElementById("ReportViewerID") returns null

Author
6 Jul 2006 6:45 PM
Billy
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,

Author
6 Jul 2006 7:00 PM
Erik Funkenbusch
On Thu, 6 Jul 2006 11:45:02 -0700, Billy wrote:

> 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.
Are all your drivers up to date? click for free checkup

Author
6 Jul 2006 7:12 PM
Billy
I copied the ID to the function in the same aspx file. I am 100% sure it is
there.


Show quoteHide quote
"Erik Funkenbusch" wrote:

> On Thu, 6 Jul 2006 11:45:02 -0700, Billy wrote:
>
> > 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.
>
Author
6 Jul 2006 7:42 PM
William Sullivan
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.

Show quoteHide quote
"Billy" wrote:

> I copied the ID to the function in the same aspx file. I am 100% sure it is
> there.
>
>
> "Erik Funkenbusch" wrote:
>
> > On Thu, 6 Jul 2006 11:45:02 -0700, Billy wrote:
> >
> > > 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.
> >
Author
6 Jul 2006 8:52 PM
Billy
William, thank you.

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

Thanks again.


Show quoteHide quote
"William Sullivan" wrote:

> 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.
>
> "Billy" wrote:
>
> > I copied the ID to the function in the same aspx file. I am 100% sure it is
> > there.
> >
> >
> > "Erik Funkenbusch" wrote:
> >
> > > On Thu, 6 Jul 2006 11:45:02 -0700, Billy wrote:
> > >
> > > > 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.
> > >
Author
6 Jul 2006 10:40 PM
Laurent Bugnion
Hi,

Billy wrote:
> 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
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Author
7 Jul 2006 6:22 PM
Erik Funkenbusch
On Thu, 6 Jul 2006 12:12:01 -0700, Billy wrote:

> 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.



Post Thread options