how to add javascript code to show alert message in code behind page

Posted by Shanky11 under JavaScript on 9/23/2013 | Points: 10 | Views : 9283 | Status : [Member] | Replies : 9
if (dt1.Rows.Count>0)
{
Response.Redirect("shoppingcart.aspx");
}
else
{
ClientScript.RegisterClientScriptBlock(GetType(), "message", "<script>alert('Please select product')</script>");


}
this is not working .............




Responses

Posted by: Shameer.Ali87 on: 9/23/2013 [Member] Starter | Points: 25

Up
0
Down
hi,
try this..

ClientScript.RegisterStartupScript(this.GetType(), "message", "alert('Please select product.');", true);

thanks


shameer ali shaik

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 9/23/2013 [Member] Starter | Points: 25

Up
0
Down
no its not wroking

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 9/23/2013 [Member] Starter | Points: 25

Up
0
Down
ClientScript.RegisterStartupScript(GetType(), "Message", "<script>alert('Please select product')</script>");
i aslo tried this

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 9/23/2013 [Member] Starter | Points: 25

Up
0
Down
if (dt1.Rows.Count>0)
{
Response.Redirect("shoppingcart.aspx");
}
else
{
ClientScript.RegisterStartupScript(GetType(), "javascript", "<script>alert('Please select product')</script>");
}
i think its fine but why its not working............

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/23/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
What about this?
if (dt1.Rows.Count>0) 

{
Response.Redirect("shoppingcart.aspx");
}
else
{
Response.Write("<script>alert('Hello');</script>"); }


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/23/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
// Try this too
ScriptManager.RegisterStartupScript(

this,
typeof(Page),
"Alert",
"<script>alert('Please select product')</script>",
false);


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/23/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer this link for further approach
http://www.aspdotnet-suresh.com/2012/04/aspnet-show-alert-message-from-code.html

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: aswinialuri-19361 on: 9/24/2013 [Member] Starter | Points: 25

Up
0
Down
hi,
try this
it will help you
Response.Write("<script>alert('welcome to my page');</script>");

Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/24/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Click on "Mark As Answer" If the above posts helped U...


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response