Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call JavaScript Function From Page Event

Status
Not open for further replies.

BDRichardson

Programmer
Jul 23, 2003
46
0
0
GB
Hi,

This problem has been baffling me for some time now.

I wish to determine the client area of a webform using JavaScript, so that I can then re-size controls appropriately within the form.

I believe that I may be able to accomplish this by somehow calling a JavaScript function from within a Page event handler. For example, when the form loads, or is resized, I could call the JavaScript function(s) and store the returned values in local C# class fields.

I also wish to store the JavaScript in an external file, and register it, probably using the 'RegisterClientScriptInclude' method.

Please can anyone clarify whether this is both feasible, and sensible solution to the problem. If so, how can I call the function from within a Page event?

I am aware that you can call JavaScript functions from within Markup code, but I believe I need to do it from within C#, because I need to use the values returned from the function to set WebForm Control properties.

Any assistance would be greatly appreciated.
 
Personally, I don't like the idea of controls being resized by the page. If I want the text to be larger, or have a bigger resolution, I can do that myself.

However, it's irrelevant that you are using ASP.NET as your server side language and all controls can be resized client-side using JavaScript. Ask in the JavaScript forum for more info but as I said, I'd advise against doing it.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
When I stated re-sizing controls, I was generalizing. But to be more specific, I need to re-size the SQL Server Reporting Services ReportViewer to a suitable size within the browser.

I will search the JavaScript forum to see if I can find some direction.

Many thanks.
 
Why define it's size absolutely then? If you set it to a percentage, it will size itself accordingly.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I have seen this mentioned once before, and am a little confused about the size as a percentage.

Are you not referring to the Zoom within the ReportViewer, as opposed to the ReportViewer control size itself?

I can only seem to control the zoom property of the report, rather than the actual size of the ReportViewer within the web form.
 
No, I mean the report viewer itself. All controls render HTML so they can be displayed on the page and therefore you can size them as you want with CSS.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Sweeeeeeet!

I have succeeded. Set the controls width to "100%", instead of "800px" and it automatically fills the width of the browser window. And the same works for the height.

Thanks so much 'ca8msm', you guided me in the right direction ;-)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top