469,914 Members | 2,480 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,914 developers. It's quick & easy.

page layout changes after response.write

Hi everyone,

string script = "";
script += "<script language='javascript'>";
script += "window.open('showdoc.aspx');";
script += "</script>";
Response.Write(script);

After the execution of this code, the layout of my aspx page changes:
the font gets bigger, the datagrid (font, grid) gets bigger, ...

So is there another way to runs a javascript in code.

thanks,

Filip
May 8 '06 #1
4 3977
Have you tried looking up Page.RegisterClientScriptBlock, or Page.
RegisterStartupScript to be used in the code behind?

May 8 '06 #2
The reason that the page changes visually is that the script you write
will end up before the doctype tag. That makes the browser ignore the
doctype, and the page is displayed in quirks mode.

Use Page.RegisterClientScriptBlock or Page.
RegisterStartupScript to add a script to the page as eruth suggested.
Then it will be placed in the code of the page and not before the code.

Filip De Backer wrote:
Hi everyone,

string script = "";
script += "<script language='javascript'>";
script += "window.open('showdoc.aspx');";
script += "</script>";
Response.Write(script);

After the execution of this code, the layout of my aspx page changes:
the font gets bigger, the datagrid (font, grid) gets bigger, ...

So is there another way to runs a javascript in code.

thanks,

Filip

May 8 '06 #3
But I want to call the javascript in my C# code.
Not in my aspx page with a html button.

When I click on an asp button, I have some cod that updates teh database and
the opens a new window.
That's the problem, with the RegisterClientScriptBlock I can't call the
javascript function in C# (I think)
"Göran Andersson" wrote:
The reason that the page changes visually is that the script you write
will end up before the doctype tag. That makes the browser ignore the
doctype, and the page is displayed in quirks mode.

Use Page.RegisterClientScriptBlock or Page.
RegisterStartupScript to add a script to the page as eruth suggested.
Then it will be placed in the code of the page and not before the code.

Filip De Backer wrote:
Hi everyone,

string script = "";
script += "<script language='javascript'>";
script += "window.open('showdoc.aspx');";
script += "</script>";
Response.Write(script);

After the execution of this code, the layout of my aspx page changes:
the font gets bigger, the datagrid (font, grid) gets bigger, ...

So is there another way to runs a javascript in code.

thanks,

Filip

May 8 '06 #4
Of course you can't call a javascript function from C#. The server code
and the client code don't exist at the same time and don't exist on the
same place. But that is not a problem.

If you don't put the javascript commands in a javascript function, they
will be executed when the page loads. Just as they did when you wrote
them out with Response.Write.

Filip De Backer wrote:
But I want to call the javascript in my C# code.
Not in my aspx page with a html button.

When I click on an asp button, I have some cod that updates teh database and
the opens a new window.
That's the problem, with the RegisterClientScriptBlock I can't call the
javascript function in C# (I think)
"Göran Andersson" wrote:
The reason that the page changes visually is that the script you write
will end up before the doctype tag. That makes the browser ignore the
doctype, and the page is displayed in quirks mode.

Use Page.RegisterClientScriptBlock or Page.
RegisterStartupScript to add a script to the page as eruth suggested.
Then it will be placed in the code of the page and not before the code.

Filip De Backer wrote:
Hi everyone,

string script = "";
script += "<script language='javascript'>";
script += "window.open('showdoc.aspx');";
script += "</script>";
Response.Write(script);

After the execution of this code, the layout of my aspx page changes:
the font gets bigger, the datagrid (font, grid) gets bigger, ...

So is there another way to runs a javascript in code.

thanks,

Filip

May 8 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Anoop | last post: by
3 posts views Thread by Andrew Jocelyn | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.