Click here to Skip to main content
15,891,730 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear friends,

Here iam going to pass querystring in window.opn script but its getting syntax error.

Iam written a code like this:

HTML
Response.Write("<script> window.open(ViewDocuments.aspx?id="+ e.CommandArgument.ToString()")</script>"));


But its showing syntax error please Modify this.let me know where iam doing mistake.


Regards,


AnilKumar.D
Posted
Updated 1-Jul-12 20:05pm
v2
Comments
Ganesan Senthilvel 2-Jul-12 2:05am    
Code format
Sandeep Mewara 2-Jul-12 2:11am    
What error? Please share.
AshishChaudha 2-Jul-12 3:05am    
Check out the link

Response.Write("<script>window.open('viewdocument.aspx?id=" + e.CommandArgument.ToString() + "');</script>");
AshishChaudha 2-Jul-12 3:05am    
its working fine for me..

Hi,

Try this:

C#
Response.Write("<script> window.open(ViewDocuments.aspx?id='"+ e.CommandArgument.ToString()+"')</script>");


But this is not best practice. Try this for best practice:
C#
string script = "window.open('popupPage.aspx'"+e.CommandArgument.ToString()+"'', 'myPopup')";
 ScriptManager.RegisterStartupScript(Page, Page.GetType(), "someId", script, true);



All the best.
--Amit
 
Share this answer
 
v3
Comments
Anil Honey 206 2-Jul-12 2:14am    
its not redirecting to ViewDocuments.aspx page
First option is to validate the content of e.CommandArgument.

Second option: If the content is in good format, then the potential problem might be in web.config. In fact, globalization of web.config, the responseEncoding should be "ISO-8859-15". The string of web.config should be:
HTML
<globalization fileencoding="ISO-8859-15" requestencoding="ISO-8859-15" responseencoding="ISO-8859-15" culture="auto" uiculture="auto" />
 
Share this answer
 
Try:
C#
// Assuming that the URL formed is correct. 
// Sure that no resolving of URL for ViewDocuments.aspx needed?
string myURL = "ViewDocuments.aspx?id="+ e.CommandArgument.ToString();
Response.Write("<script> windows.open(" + myURL + ");</script>");

Looked like you missed closing bracket in your implementation.


UPDATE:
Just in case, if your ViewDocuments.aspx link needs correct URL, use ResolveURL method to get the correct redirect URL and then use the same.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900