473,324 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

RegisterStartupScript

Nic
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.Unesca pe(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.s howModalDialog('ZoekDossierOhra.aspx',null,'status :no;dialogWidth:370px;dialogHeight:220px;dialogHid e=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

Nov 16 '05 #1
1 7195
Hi

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

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;d ialogHide=true;help:no;scroll:no');
}
--
--
Ravikanth[MVP]
"Nic" wrote:
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.Unesca pe(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.s howModalDialog('ZoekDossierOhra.aspx',null,'status :no;dialogWidth:370px;dialogHeight:220px;dialogHid e=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

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Lukman | last post by:
Hi, Could you tell me about what is RegisterStartupScript, I try to understand from MSDN sample, but I still don't understand. Could you give me more simple sample ? and what is the purpose of...
6
by: Bill Jones | last post by:
I'm trying to use this.RegisterStartupScript to add some javascript to and aspx page that will run when the page is loaded. Does anyone know if this function only works in the Page_Load function? ...
11
by: Stan Sainte-Rose | last post by:
Hi, I m working on a user control. I need to use a Js file, I would like to know how to load the js file using RegisterStartupScript command from the user control. Also, if I load the same user...
3
by: Mike | last post by:
Hi, I am trying to resize a HTML table through Javascript. When the user control loads the first time, the table is resized, but then it doesn't anymore. I am using the following code in the...
2
by: Marshal Antony | last post by:
Hi, I have a problem with using Page.RegisterStartupScript to call some javascript code from ASP.NET using C# is not working in Netscape.It is working fine in Internet Explorer.Does anybody know...
0
by: rom | last post by:
my main aspx page has 3 user controls. they are all located in the same place of the page and each time i set the visibility of 2 of them to false and 1 to true. now, i want to use the...
7
by: sck10 | last post by:
Hello, I have the following sub in a class in my "App_Code" directory. The script is for setting focus on a particular control, but I get the error, "Name ClientScript Not declared". Also, I am...
3
by: MJP | last post by:
I have a button which kicks off the generation of a report after which the file will be downloaded. The report generation can take a long time, so client side onclick event of the button also...
3
by: Rob | last post by:
Hi, We've developed an ajax enabled web app which we're currently deploying to our production server. We use System.Web.UI.Page.RegisterStartupScript throughout the app, and all has worked well...
4
by: =?Utf-8?B?RHVuZTg4?= | last post by:
I've got some code that uses Page.ClientScript.RegisterStartupScript to call a javascript function from the Page_Load method in the code behind. The code works fine in IE but the javascript...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.