473,385 Members | 1,555 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,385 software developers and data experts.

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_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{

}

Do you know of any way of kicking off the SetUnSavedChanges 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 SetUnSavedChanges(callBackPanel)
{
UnSavedChanges = true;
}
function SetSavedChanges(callBackPanel)
{
UnSavedChanges = false;

}
function AdminTabStripHandler(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 1452
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.RegisterStartupScript(this, this.GetType(),
typeof(TYPE_OF_CONTAINING_PAGE).FullName, script, true);

if not

ClientScriptManager.RegisterStartupScript( ... );

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*********@discussions.microsoft.comwrote in message
news:67**********************************@microsof t.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_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{

}

Do you know of any way of kicking off the SetUnSavedChanges 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 SetUnSavedChanges(callBackPanel)
{
UnSavedChanges = true;
}
function SetSavedChanges(callBackPanel)
{
UnSavedChanges = false;

}
function AdminTabStripHandler(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
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...
5
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
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...
3
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...
4
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...
6
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...
4
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...
4
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...
9
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...
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...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.