Hemant Kumar
Hemant Kumar

Reputation: 4611

Message box on server side in asp.net

i have button click handler event in which i am using if-else condition.How can i show a message if it runs to else statement? Like please fill the requirements!!.

Upvotes: 0

Views: 3261

Answers (2)

anishMarokey
anishMarokey

Reputation: 11397

you can use javascript in .cs

Page.ClientScriptBlock.RegisterStartupScript(Page. GetType(), "Key", "alert('message');", true);

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1038730

You could use the RegisterStartupScript method:

ClientScript.RegisterStartupScript(GetType(), "someKey", "alert('oops');", true);

But for this kind of things probably it's better to use validation controls (can't say for sure as you haven't specified any context nor explained the logic).

Upvotes: 2

Related Questions