473,683 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling javascript from asp.net c# application

Hi,
I have a the following javascript code(see below) within my asp.net page,
I would like to be able to set the value of UnSavedChanges within my c#
behind code to indicate that changes have been made but not yet saved.
For Example I have a gridview rowUpdating event as follows

protected void gvwCommodity_Ro wUpdating(objec t sender,
GridViewUpdateE ventArgs e)
{

}

Do you know of any way of kicking off the SetUnSavedChang es event within
this method or setting the UnSavedChanges variable any other way..

Thanx in advance

Robert

///Javascript code below
/// this code uses essential objects and works on the callback panel
onClientClick
// event

var UnSavedChanges

function SetUnSavedChang es(callBackPane l)
{
UnSavedChanges = true;
}
function SetSavedChanges (callBackPanel)
{
UnSavedChanges = false;

}
function AdminTabStripHa ndler(e, eventInfo)
{
if (UnSavedChanges == true)
{
var RetVal = confirm("Are you Sure you want to leave this screen
without saving changes");
if (RetVal == true)
{
SetSavedChanges ();
}
return RetVal;
}
}
Jun 27 '08 #1
1 1463
If you are using AJAX.NET you can use something like that:

string script = "alert('Hello') "; // put here any script you want,
e.g. call the function.

ScriptManager.R egisterStartupS cript(this, this.GetType(),
typeof(TYPE_OF_ CONTAINING_PAGE ).FullName, script, true);

if not

ClientScriptMan ager.RegisterSt artupScript( ... );

Anyone of above methods will add supplied script to the page and execute
it. "AJAX.NET way" will do it without page postback.
Artur

"Robert Smith" <Ro*********@di scussions.micro soft.comwrote in message
news:67******** *************** ***********@mic rosoft.com...
Hi,
I have a the following javascript code(see below) within my asp.net
page,
I would like to be able to set the value of UnSavedChanges within my c#
behind code to indicate that changes have been made but not yet saved.
For Example I have a gridview rowUpdating event as follows

protected void gvwCommodity_Ro wUpdating(objec t sender,
GridViewUpdateE ventArgs e)
{

}

Do you know of any way of kicking off the SetUnSavedChang es event within
this method or setting the UnSavedChanges variable any other way..

Thanx in advance

Robert

///Javascript code below
/// this code uses essential objects and works on the callback panel
onClientClick
// event

var UnSavedChanges

function SetUnSavedChang es(callBackPane l)
{
UnSavedChanges = true;
}
function SetSavedChanges (callBackPanel)
{
UnSavedChanges = false;

}
function AdminTabStripHa ndler(e, eventInfo)
{
if (UnSavedChanges == true)
{
var RetVal = confirm("Are you Sure you want to leave this screen
without saving changes");
if (RetVal == true)
{
SetSavedChanges ();
}
return RetVal;
}
}

Jun 27 '08 #2

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

Similar topics

18
12683
by: Simula | last post by:
I am developing an HTML javascript application and I want to preserve state in a way that can be book-marked. I chose HTML anchors as a means of preserving state. When the application changes state, the HTML page URL would change from default.html to default.html#stateA. example: http://pearstudios.com/javascript/locationHashAndFlash.html This has worked perfectly within HTML and javascript alone, however, when connecting Flash and...
5
51479
by: Krishna | last post by:
Hi all, Can i call my javascript functions from the web controls.Any appropriate site which will be tell more on this will be helpfull. Regards.., Krishna
4
6321
by: Martin Feuersteiner | last post by:
Dear Group I'm using VB to write an aspnet application. I would like to call a javascript function from within a VB Sub or VB Function, is it possible? My code is something like this: VB Code: Public Sub VBProcedure() .. ..
3
3574
by: Opa | last post by:
Hi , I have a form with javasript which launches a popup via the showModalDialog() method. I get the dialog to open, now I am trying to first get a reference to the calling form from the popup and then do a refresh of the calling form. Any ideas on how to get a reference to the calling form? I tried window.parent.location.reload() , but it doesn't work. Thanks a lot.
4
2225
by: muralidhargvn | last post by:
Hi, I have an asp application with business logic written in JavaScript file. Also I had created a C# windows application. Now I want to call a method of my C# application from the JavaScript function. Can anyone help in solving my problem? Thanks, GVN.
6
10621
by: Ajit Goel | last post by:
Hi; We have a Javascript function which I have been tasked to move to a CSharp class. This javascript function uses Regular expression extensively. This function has a string input parameter and output parameter. My questions are: a. Can I expose a function in my CSharp code and internally call a javascript function?? Is this a good idea?? b. Do we have any tool which can convert a javascript function into
4
3869
by: gengyue | last post by:
Hi, I need to call .Net webservice from my JSP page. My application is Struts application. It is deployed on Oracle application server. Here is the whole process. I have a login form. When user hit login button, my Action class will validate the user information and send his information to the other site by calling .Net web service, so the other site can extract these information. So, in my jsp, I am using Javascript and webservice.htc to...
4
4115
by: gengyue | last post by:
Hi, I need to call .Net webservice from my JSP page. My application is Struts application. It is deployed on Oracle application server. Here is the whole process. I have a login form. When user hit login button, my Action class will validate the user information and send his information to the other site by calling .Net web service, so the other site can extract these information. So, in my jsp, I am using Javascript and webservice.htc to...
9
3022
by: mrcheeky | last post by:
Hi, I'm stuck, but it's almost working! From a html page, my javascript calls a server-side php script. The php reads a value from a server-side .txt file and passes it back as a javascript variable. This all works fine. However, I want it to loop within a javascript function every 5 seconds. The function does other stuff, so looping within this function is essential (I've simplified it in the example below). Any advice would be...
0
8568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9042
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8751
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6429
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5789
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2195
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.