In this post, I will explain how to use JavaScript Prompt dialog box in Asp.Net?.
While writing program much time a situation comes where the programmer wants to pop-up a text box to get user input and this can be done by using JavaScript Prompt Dialog box. JavaScript supports three important types of dialog boxes. These dialog boxes can be used to raise an alert, or to get confirmation on any input or to have a kind of input from the users. Here we will discuss Prompt Dialog Box.
While writing program much time a situation comes where the programmer wants to pop-up a text box to get user input and this can be done by using JavaScript Prompt Dialog box. JavaScript supports three important types of dialog boxes. These dialog boxes can be used to raise an alert, or to get confirmation on any input or to have a kind of input from the users. Here we will discuss Prompt Dialog Box.
A Prompt dialog box is very useful when we want to pop-up a text box to get user input. User needs to fill the text box field and then click OK.
A Prompt dialog box is displayed using a method prompt(). The prompt method takes two parameters:
1. A label which you want to display
2. A default string to display in the text box
A Prompt dialog box gives two buttons:
1. A label which you want to display
2. A default string to display in the text box
A Prompt dialog box gives two buttons:
1. OK - If a user clicks the OK button, prompt() method returns a value from a text box
2. Cancel - If a user clicks the Cancel button, the prompt() method returns a null value
2. Cancel - If a user clicks the Cancel button, the prompt() method returns a null value
HTML Code -
<html lang=""><head>
<title>How to use JavaScript Prompt Dialog Box in Asp.Net</title>
<script type="text/javascript">
function PromptUser(){
var retVal = prompt("Please enter your choice (1,2 or 3) : ", "Enter your choice here");
document.getElementById("enteredChoice").innerText = "Your choice is : " + retVal;
}
</script>
</head>
<body>
<form>
<input type="button" value="Click me to propmt a textbox" onclick="PromptUser();" />
</br>
<h1 id="enteredChoice"></h1>
</form>
</body>
</html>
0 comments:
Post a Comment
Please do not enter any spam link in the message box.