473,785 Members | 2,969 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling Javascript

I am trying to call a javascript from Datagrid which is using
OnUpdatecommand , I dont see update being invoked, what am I missing, Is
it the right way to call. I have just cut and pasted only the part of
the code. Thanks

In the class file:
public void DataGrid2_Edit( Object sender, DataGridCommand EventArgs e)
{
DataGrid2.EditI temIndex = (int)e.Item.Ite mIndex;
BindGrid();

TableCell cell = (TableCell) e.Item.Controls[0];
System.Web.UI.W ebControls.Link Button lnk=
(System.Web.UI. WebControls.Lin kButton ) cell.Controls[0];
lnk.Attributes. Add("onclick"," javascript:conf irm_update();") ;
}

Html:
</style>
<script language="javas cript">
function confirm_update( )
{
if(confirm("Are you sure you want to update?")==true )
return true;
else
return false;
}
</script>
</HEAD>
<BODY>
<form id="Form1" method="post" runat="server">
<h2>Customer Fleet Edit Screen For:
<asp:Label id="Label1" runat="server"
Width="112px">L abel</asp:Label></h2>
<asp:datagrid id="DataGrid2" runat="server"
AutoGenerateCol umns="false" OnUpdateCommand ="DataGrid2_Upd ate"
OnCancelCommand ="DataGrid2_Can cel" OnEditCommand=" DataGrid2_Edit"
HeaderStyle-BackColor="#aaa add"

Oct 5 '06 #1
5 1719
Not sure if this will fix it, but where you add the attribute for
onclick event, you aren't returning the result of the method.
So the clicking may not occur.

lnk.Attributes. Add("onclick"," javascript:conf irm_update();") ;

becomes

lnk.Attributes. Add("onclick"," return confirm_update( );");

Oct 5 '06 #2
q
The problem is that you are in a JavaScript blocking declaring a
JavaScript inline block. Just call the function. You only need the
JavaScript inline block for things like href in an anchor.

On Oct 5, 5:45 pm, "Steven Nagy" <learndot...@ho tmail.comwrote:
Not sure if this will fix it, but where you add the attribute for
onclick event, you aren't returning the result of the method.
So the clicking may not occur.

lnk.Attributes. Add("onclick"," javascript:conf irm_update();") ;

becomes

lnk.Attributes. Add("onclick"," return confirm_update( );");
Oct 5 '06 #3
still not able to get it working.
I need to do other validation in the update, thats why I need to call
the javascript on the updateevent. Any other clues ?

Thanks

q wrote:
The problem is that you are in a JavaScript blocking declaring a
JavaScript inline block. Just call the function. You only need the
JavaScript inline block for things like href in an anchor.

On Oct 5, 5:45 pm, "Steven Nagy" <learndot...@ho tmail.comwrote:
Not sure if this will fix it, but where you add the attribute for
onclick event, you aren't returning the result of the method.
So the clicking may not occur.

lnk.Attributes. Add("onclick"," javascript:conf irm_update();") ;

becomes

lnk.Attributes. Add("onclick"," return confirm_update( );");
Oct 5 '06 #4
Is your javascript function have not been called or the page have been
posted back before your javascript have been called. Also please can u
tell me what the linkbutton tag client source contains (Anchor tag
that's been formed due to link button's html).

sr************* *@gmail.com wrote:
still not able to get it working.
I need to do other validation in the update, thats why I need to call
the javascript on the updateevent. Any other clues ?

Thanks

q wrote:
The problem is that you are in a JavaScript blocking declaring a
JavaScript inline block. Just call the function. You only need the
JavaScript inline block for things like href in an anchor.

On Oct 5, 5:45 pm, "Steven Nagy" <learndot...@ho tmail.comwrote:
Not sure if this will fix it, but where you add the attribute for
onclick event, you aren't returning the result of the method.
So the clicking may not occur.
>
lnk.Attributes. Add("onclick"," javascript:conf irm_update();") ;
>
becomes
>
lnk.Attributes. Add("onclick"," return confirm_update( );");
Oct 6 '06 #5
q
Anything in the quotes is javascript: onclick=""

Never put "javascript : " in there, because that's not JavaScript. It's
already JavaScript. You just need to call the function like
onClick="Confir mUpdate( );" or if you need a return, go ahead.
sr************* *@gmail.com wrote:
still not able to get it working.
I need to do other validation in the update, thats why I need to call
the javascript on the updateevent. Any other clues ?

Thanks

q wrote:
The problem is that you are in a JavaScript blocking declaring a
JavaScript inline block. Just call the function. You only need the
JavaScript inline block for things like href in an anchor.

On Oct 5, 5:45 pm, "Steven Nagy" <learndot...@ho tmail.comwrote:
Not sure if this will fix it, but where you add the attribute for
onclick event, you aren't returning the result of the method.
So the clicking may not occur.
>
lnk.Attributes. Add("onclick"," javascript:conf irm_update();") ;
>
becomes
>
lnk.Attributes. Add("onclick"," return confirm_update( );");
Oct 6 '06 #6

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

Similar topics

7
4522
by: Julia Briggs | last post by:
Hello World - I admit I'm new to javascript but I've tried for days to find a solution to my problem. Basically I have 3 unique javascript files that do different screen display events that I want to dynamically call, where the current page would then refresh after a user clicks on any one of three associated button links. Could someone please assist me and craft a simple script that would accomplish this feat of impossibility? ...
18
12700
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
51483
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
1
1946
by: desmcc | last post by:
Hi, I am launching a modal dialog through the usual javascript (window.showmodaldialog). When the modal dialog is complete (ie user selects OK), the calling page then refreshes itself by setting the location.href of the window to be itself (ie the modal dialog changes a label on the calling page ). I can see that this causes the page load code of the calling page to execute in the code behind page. I can also see clearly that this updates...
4
6336
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() .. ..
13
6716
by: ukrbend | last post by:
I'm new to Javascript and to html and am trying to make the following code snippet work but it doesn't. It refuses to call the getPage() function and I always get a 404 error. I know the code is getting as far as the iframe section as other parts of the html code work correctly. But it is not executing any code within the getPage() function as some "hello world" writes within getPage() wouldn't print. ...
3
3581
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
2822
by: Adam Smith | last post by:
Hello, How can I call or trigger an external javascript twice in a form? I have <script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript" src="country_state.js"> </script>
5
3248
by: Newbie Coder | last post by:
Hello all I have 3 functions in a javacrip file (MyScript.js), which is added to an ASP.NET 2.0 project 1) no right-click 2) no select text (copy...) 3) History.Back()' How do I call those 3 functions in all of my pages?
6
10631
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
0
9645
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
10325
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...
0
10148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
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
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6740
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.