Javascript and C#

M

Marius Horak

Hi,

When a button is pressed the user is prompted to confirm if the data should
be either deleted or archived.
Next in code-behind the application will do some data processing and after
that depending on the user answer different procedures will be called.
I can show dailog box but I'm not able to get the JavaScript return value to
my C# code..

This is what I have (the value of DA is always empty string):

protected System.Web.UI.HtmlControls.HtmlInputHidden YN;

private void Page_Load(object sender, System.EventArgs e)
{
string js = "javascript:"+
"if (confirm('Delete data ?')) document.Form1.DA.Value = 'D'; else
document.Form1.DA.Value = 'A';";
Button.Attributes.Add("onclick",js);
}

private void Button_Click(object sender, System.EventArgs e)
{
HtmlInputHidden da = (HtmlInputHidden)this.FindControl("DA");
if (da.Value == "D")
DeleteDate();
if (da.Value == "A")
ArchiveData();
}

I search the net but did not find anything else apart from using a hiddent
control. But it does not work for me.
How can I get this return value?

Thanks

MH


PS. My boss wants dialog box, not a check box or drop down list or another
form.
 
D

DuffDuff

you don't need to cast your hidden field into a hiddenControl just use :

String test = request.form("DA");

it should work
 
M

Marius Horak

DuffDuff said:
you don't need to cast your hidden field into a hiddenControl just use :

String test = request.form("DA");

it should work

Did you test it?
In what language is your code?

MH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top