AJAX avoid using Reponse.write
-
Our company is wanting to implement AJAX and it has been my task to get everything up and running. One of the major issues that I have run into is throughout our application we use response.write to use JavaScript files in our basepage. See Example: Response.Write("") Response.Write("") I have been trying for the page few days to use ClientScript.RegisterStartupScript or ClientScript.RegisterClientScriptBlock()but with no luck. My Ajax section is working without the response.write but with them I get the dreaded sys.webforms.pagerequestmanagerparserErrorException error. Any kind of suggestions will be great. Thanks, Cisco2103
-
Our company is wanting to implement AJAX and it has been my task to get everything up and running. One of the major issues that I have run into is throughout our application we use response.write to use JavaScript files in our basepage. See Example: Response.Write("") Response.Write("") I have been trying for the page few days to use ClientScript.RegisterStartupScript or ClientScript.RegisterClientScriptBlock()but with no luck. My Ajax section is working without the response.write but with them I get the dreaded sys.webforms.pagerequestmanagerparserErrorException error. Any kind of suggestions will be great. Thanks, Cisco2103
Why is it necessary to write out the script tags? Can't they just be placed on the page directly? You need to add these to the header section of the page. RegisterClientScript places them in form. You could try overriding the Init or PreInit for the page and inserting them then.
only two letters away from being an asset
-
Why is it necessary to write out the script tags? Can't they just be placed on the page directly? You need to add these to the header section of the page. RegisterClientScript places them in form. You could try overriding the Init or PreInit for the page and inserting them then.
only two letters away from being an asset
-
I've tried putting them in the header section of the page but with no luck. Not very familiar with Init and PreInit since I am pretty new to .Net What would I accomplish by doing this?
cisco2103 wrote:
I am pretty new to .Net
Perhaps you should step back do some research first.
only two letters away from being an asset
-
I've tried putting them in the header section of the page but with no luck. Not very familiar with Init and PreInit since I am pretty new to .Net What would I accomplish by doing this?
cisco2103 wrote:
I've tried putting them in the header section of the page but with no luck.
Just add
Literal
controls with the script as text, as children toPage.Header
.cisco2103 wrote:
Not very familiar with Init and PreInit since I am pretty new to .Net What would I accomplish by doing this?
Nothing, really. It doesn't matter much when you add the controls to the page, as long as it's done before the renderinging, and that only rules out the
Unload
andDisposed
events, AFAIK.--- single minded; short sighted; long gone;
-
cisco2103 wrote:
I am pretty new to .Net
Perhaps you should step back do some research first.
only two letters away from being an asset
-
Our company is wanting to implement AJAX and it has been my task to get everything up and running. One of the major issues that I have run into is throughout our application we use response.write to use JavaScript files in our basepage. See Example: Response.Write("") Response.Write("") I have been trying for the page few days to use ClientScript.RegisterStartupScript or ClientScript.RegisterClientScriptBlock()but with no luck. My Ajax section is working without the response.write but with them I get the dreaded sys.webforms.pagerequestmanagerparserErrorException error. Any kind of suggestions will be great. Thanks, Cisco2103
Use RegisterClientScriptBlock to add javascript to your page. Better yet, as you're referencing .js files ( which is always better ), just put the code direct into the aspx. I tend to use registerclientscript block to create variables in my script which give me the names of ASP.NET generated controls, so I can interact with them in my javascript/AJAX code.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )