Avatar of ankuratvb
ankuratvb
Flag for United States of America asked on

Get Prompt Result in Server Side Code

Hi,

This is what i need.

I have a webform.When the user clicks a button,i need to ask the user for a value which i use for
furthur processing.

I need some way to get the value from the user and use it in my server side code. I tried using
InputBox but it gives me an error saying that to use inputbox i need to have a modal application
or use a service(smoething along these lines).

So,i tried using javascript's window.prompt and then trigger the server side event by generating a
button click when the user has entered a value.
So,i do:
perc=window.prompt("Enter Percentage Value:")
document.Form1.txtval.value=perc;
document.Form1.btn.click();

but the click statement gives me an error saying contentWindow.document is null or not an object.
i tried using Form1.btn.click() but still doesnt work.
If i remove the click statement, then the value is put in the textbox but i need an event to be triggered
to process furthur.

Can you help me in doing this?
Any Help would be greatly appreciated.
Thanx.
ASP.NET

Avatar of undefined
Last Comment
boulder_bum

8/22/2022 - Mon
Hamed Zaghaghi

hi,

if you want to get a confirmation from the user, for example you want to ask the user that does he/she want to delete an Item?

so you can write a java script function that return a boolean value, and in this function you call the prompt, and if user say Yes to prompt, return true, and else return false;

and then in the button tag in html view write this function on 'onclick' event of the button
for example:
<.......         onclick="functionname()" >

have good programming day;
--hamed
ankuratvb

ASKER
What i need is the user to enter a value which i have to store in a database.

For e.g. i ask him for a number and i store the number in the database
ASKER CERTIFIED SOLUTION
boulder_bum

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23