How to stop rendering to browser when input is correct
-
I'm making an webapplication which is using a lot of modalpages. By this way it just works like a normal application. Because this application is running on the internet, performance is an big issue. We want to keep the trafic to client and server as small as possible. We have build some user controls to render content by javascript to make the data overhead as less as possible. Now i was thinking about the way the pages are processing in my application. And i mean the modal pages. And i came to the following - Server rendering page - Send page to client - Client inputs page - Page is send back to server - Input is processed - Page is again rendered at the server (now as a postback page, where a closing javascript is put to the end of the road) - Page is sended again to the client where it will be closed by the javascript After the input of the client and the second time the page is rendered, there is a lot of data overhead. I want only the javascript to be rendered to the page. I started to make an PageBase which is derived from Page object and where all the modal pages will be build on. But i get some problems with it. In the PageBase render function i do the following thing
protected override void Render(HtmlTextWriter writer) { if(!Page.IsPostBack) { base.Render(writer); } }
This is working fine and i can read the information in the Save Method of a page which is based on this class and the close the page. But this solution is not perfect because when i want to use validators which are working server side, then i should rebuild the page. I can extend the Render code by validating the page and if the page is not valid i can render the content to the server with base.Render(writer) but this render function is after the save method and so i had to validate the page two times (in the render method and in the save method) And an other thing is that we have a try and catch in the save method to catch database exception or something else where we want the page also to be rebuilded so that the user can try it again posting his input without the page being closed and the input being lost. So my point is, is there someone who has a solution for my problem(s). I know that i can render all the controls at runtime and do not rendering them at postback time but we want design and programming logic to be seperated. I hope somebody can help me. If you want more information about my problems (because you don't understand it all the way which can be possible -
I'm making an webapplication which is using a lot of modalpages. By this way it just works like a normal application. Because this application is running on the internet, performance is an big issue. We want to keep the trafic to client and server as small as possible. We have build some user controls to render content by javascript to make the data overhead as less as possible. Now i was thinking about the way the pages are processing in my application. And i mean the modal pages. And i came to the following - Server rendering page - Send page to client - Client inputs page - Page is send back to server - Input is processed - Page is again rendered at the server (now as a postback page, where a closing javascript is put to the end of the road) - Page is sended again to the client where it will be closed by the javascript After the input of the client and the second time the page is rendered, there is a lot of data overhead. I want only the javascript to be rendered to the page. I started to make an PageBase which is derived from Page object and where all the modal pages will be build on. But i get some problems with it. In the PageBase render function i do the following thing
protected override void Render(HtmlTextWriter writer) { if(!Page.IsPostBack) { base.Render(writer); } }
This is working fine and i can read the information in the Save Method of a page which is based on this class and the close the page. But this solution is not perfect because when i want to use validators which are working server side, then i should rebuild the page. I can extend the Render code by validating the page and if the page is not valid i can render the content to the server with base.Render(writer) but this render function is after the save method and so i had to validate the page two times (in the render method and in the save method) And an other thing is that we have a try and catch in the save method to catch database exception or something else where we want the page also to be rebuilded so that the user can try it again posting his input without the page being closed and the input being lost. So my point is, is there someone who has a solution for my problem(s). I know that i can render all the controls at runtime and do not rendering them at postback time but we want design and programming logic to be seperated. I hope somebody can help me. If you want more information about my problems (because you don't understand it all the way which can be possibleif have solve this problem by making an property in the PageBase which can be true or false. I called the property RebuildPage. By default this is false and if i want the page to be restored i set it to true. The render method of the Pagebase is changed to this
protected override void Render(HtmlTextWriter writer) { if(!Page.IsPostBack || this._rebuildpage != false) { base.Render(writer); } }
When at the save method there goes something wrong, i just set RebuildPage to true and the page will be rendered. Otherwise i can just generate a close screen script