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

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, DataGridCommandEventArgs e)
{
DataGrid2.EditItemIndex = (int)e.Item.ItemIndex;
BindGrid();

TableCell cell = (TableCell) e.Item.Controls[0];
System.Web.UI.WebControls.LinkButton lnk=
(System.Web.UI.WebControls.LinkButton ) cell.Controls[0];
lnk.Attributes.Add("onclick","javascript:confirm_u pdate();");
}

Html:
</style>
<script language="javascript">
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">Label</asp:Label></h2>
<asp:datagrid id="DataGrid2" runat="server"
AutoGenerateColumns="false" OnUpdateCommand="DataGrid2_Update"
OnCancelCommand="DataGrid2_Cancel" OnEditCommand="DataGrid2_Edit"
HeaderStyle-BackColor="#aaaadd"

Oct 5 '06 #1
5 1689
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:confirm_u pdate();");

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...@hotmail.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:confirm_u pdate();");

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...@hotmail.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:confirm_u pdate();");

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...@hotmail.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:confirm_u pdate();");
>
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="ConfirmUpdate( );" 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...@hotmail.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:confirm_u pdate();");
>
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
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...
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
1
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...
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...
13
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...
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: 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"...
5
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...
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.