| re: page layout changes after response.write
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:[color=blue]
> 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:
>[color=green]
>> 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:[color=darkred]
>>> 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[/color][/color][/color] |