开发者

Issues with displaying messagebox in asp.net

I have the following message box in c# on my asp.net page inside the btnSubmit_Click event. It tends to popup sometimes and not popup sometimes. Any reasons as to why it is not consistent?

Clie开发者_运维知识库ntScript.RegisterStartupScript(
    GetType(),
    "alert",
    "alert('An email has been sent to Customer Service');",
    true);


I guess that this will depend on the text you are putting inside the alert. In the example you provided the text is hardcoded but I suppose that in your real application this text is dynamic and might contain characters that break javascript such as '. Try using FireBug to see if there are some javascript errors when it doesn't work.


Have You checked, if the alert('An email has been sent to Customer Service'); line is in the HTML Source after you clicked the Button and the message did NOT appear?

If it isn't in the HTML, check:

  1. with the Debugger if your codeblock is hit
  2. are you maybe redirecting the response?


try these popups instead type java directly in the visualstudio GUI

On a button go to the "OnClientClick" property (its not into events*) over there type:

 return confirm('are you sure?')

it will put a dialog with cancel ok buttons transparent over current page if cancel is pressed no postback will ocure. However if you want only ok button type:

 alert ('i told you so')

The events like onclick work server side they execute your code, while OnClientClick runs in the browser side. the come most close to a basic dialog

as this codes is so small it should work unless they have really strange browser clients

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜