Click to See Complete Forum and Search --> : Send web page in pieces with correct html rendered?
overthetop
04-19-2007, 04:02 AM
Hi
I want to send my aspx page in peices. I send a html div tag first in the page Init handler:
string div = @"<div>fisrt div</div>";
Response.Write(div);
Response.Flush();
And after that leave the page to execute normally.
The result is that my div element is placed before the DOCTYPE otside the html and body tags. How can I do it so that the html rendered will be correct? It's important to send the page in pieces.
10x
PeOfEo
04-19-2007, 10:19 AM
Why?
You can just put elements on the page and set their visibility to false at the server, or you can set the text of webforms elements.
<div runat="server" visible="false">
this will not even appear in your markup until you set the visibility to true.
I am not sure if that helps any or not. I guess I do not really understand the question. What is the big picture, what are you trying to accomplish exactly?
overthetop
04-19-2007, 10:40 AM
No this is not what i meant. This is a piece of the big picture: I want to disable right click even before the page is loaded in the browser. Don't ask me why! :) the page is not viewed in regular html browser, so view source is not available from the menu. So back to the picture :), in order to disable right click before the page starts loading I send the page in pieces, the first piece is the js and the second is the whole page. I need to make the rendered html valid because it mess up the css of the sait. Is there any way to do it?
PeOfEo
04-19-2007, 11:15 AM
No, not really. Not if this thing has to validate. But if you, in your aspx file, supply the doc type you should be able to just put your javascript function before the doctype. But, that javascript needs to be somewhere on the page, not 'before the page'. I don't see why you can't just stick it in the head of the page and have the same affect.
overthetop
04-19-2007, 01:07 PM
because I am dump :eek:
10x man you made my day :)
overthetop
04-19-2007, 01:08 PM
but you know, the QA have the final word ;)
PeOfEo
04-19-2007, 01:27 PM
np, gl
Ribeyed
04-19-2007, 04:23 PM
Hi,
i think you achieve what you are trying to do if you use the RegisterClientScriptResource method in the ScriptManager Class.
You can load a script file from the resources of the page assembly. You add a script file to the project as an embedded resource. You then link the code to the page using the RegisterClientScriptResource method.
The WebResource.axd HTTP Handler is used to load the specified script from the resources of the page assembly.