RegisterStartupScript

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey,
Problems.

I have an asp form with an textbox and a button.
When I click the button I want to check te content of the textbox.

private void NextButton_Click(object sender, System.EventArgs e)
{
this.CheckInteger(TextBox1.text);
........
}

private void CheckInteger(string itext)
{
int i = 0;
try { Int32.Parse(itext); }
catch
{
const string script =
"<script language=\"javascript\">" +
"alert('Not an integer');" +
// "if(confirm('Geen integer')){}else{return false};" +
"</script>";

Page.RegisterStartupScript("CheckInt",Regex.Unescape(string.Format(script)));
}

I thought that an alert will be shown on screen, but nothing happens. Why?

Struggeling with these things. I just want to check some input and show a dialogbox to the user.

I also tried :
this.NextButton.Attributes.Add("onclick","window.showModalDialog('ZoekDossierOhra.aspx',null,'status:no;dialogWidth:370px;dialogHeight:220px;dialogHide=true;help:no;scroll:no');");

But I only want too show this dialogbox not in all circumstances, just when lets say the input is not an integer.

Thanks in advance,
Nic
 
Hi

Add a javascript function call in onclick of button.
Ex:
this.NextButton.Attributes.Add("onclick","doVerification()");

In javascript of the page implement the code:
function doVerification()
{
// logic for verification depending on condition show modal dialog
window.showModalDialog('ZoekDossierOhra.aspx',null,'status:no;dialogWidth:370px;dialogHeight:220px;dialogHide=true;help:no;scroll:no');
}
 

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

Back
Top