Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I got this code and my problem the javascript doesnt load
C#
if (projectID != "0")
       {
           Response.Redirect("ProjectDetails.aspx");
       }

      if (projectID == "0")
       {
           Response.Write("<script>alert('Please Select')</script>");
         
       }
Posted
Comments
Sandeep Mewara 16-Jul-12 11:03am    
This is not a well framed question! We cannot work out what you are trying to do/ask from the post. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.
[no name] 16-Jul-12 11:05am    
How do you know that "javascript doesnt load"? You do know what Response.Write does don't you?

I believe the issue is in your script tag. You need to specify the language as javascript. You also need to put a semicolon at the end of your javascript line. The result should look like this (ignore the double-quotes around javascript - it is a bug in the CP editor that I can't get around):

C#
if (projectID != "0")
{
   Response.Redirect("ProjectDetails.aspx");
}

if (projectID == "0")
{
   Response.Write("<script language='javascript'>alert('Please Select');</script>");
 
}


Here is a MSDN question with more information and help:

http://forums.asp.net/t/1051178.aspx/1[^]
 
Share this answer
 
v2
Comments
Sandeep Mewara 16-Jul-12 11:29am    
Looks like above addition of quotes will raise compile error! Though, OP should have got the essence of it.

BTW, I am still unclear on how it is implemented.
Raje_ 16-Jul-12 13:21pm    
yes Sandeep is right the correct code would be:
Response.Write("<script language=javascript>alert('Please Select');</script>");
Tim Corey 16-Jul-12 14:05pm    
That is the code I tried to post (only I included single quotes around javascript) but as I posted in my response, the CP editor would not let me put just single quotes - it added the extra double-quotes automatically and I couldn't take them out.
Sandeep Mewara 17-Jul-12 1:52am    
Thats fine. Your point was to direct user and it was done. :thumbsup:
Hi,
Try this:
C#
if (projectID != "0")
       {
           Response.Redirect("ProjectDetails.aspx");
       }

      if (projectID == "0")
       {
           Response.Write("<script language='javascript'>alert('Please Select');</script>");

       }

--Amit
 
Share this answer
 
v3
Comments
Raje_ 16-Jul-12 13:23pm    
Are u sure this code would work, i think it will give compile time error in second Resplone.Write() method, here i think we have to remove the quotes in javascript word:-
Response.Write("<script language=javascript>alert('Please Select');</script>");
Or we can use single quote.
Tim Corey 16-Jul-12 14:06pm    
I'm not sure I see the difference from what I posted an hour earlier. Did you do something I missed?
Mphirana 17-Jul-12 2:08am    
I tried both but messagebox still doesnt show, on bottom of the page writes javascipt:void(0)
_Amy 17-Jul-12 4:42am    
Actually i tried writing
Response.Write("<script language='javascript'>alert('Please Select');</script>");
But after writing this in the solution it is coming like above one..

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