472,958 Members | 2,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Calling Javascript from ASP NET

Hi Can anyone help me?

I have a Javascript function in my test.aspx as follow:-

<script language="Javascript">

function confirm_save()
{
if (confirm("Are you sure you want to save this changed?")==true)
return true;
else
return false;
}

</script>


Note:-
1. I know this can be called by <input .... type BUTTON and
2. <linkbutton....
3. <asp:button....


BUT My case is different, as follows:-

I have a datagrid to display in the test.aspx, the datagrid have a EDIT button, and this button is not customize by me, when I configure property builder of the datagrid, I simply add it (template column).


If you take a look at the HTML test.aspx, you can notice below:-


<TR>
<TD bgColor="inactivecaptiontext" colSpan="2"><asp:datagrid id="datagrid" runat="server" CssClass="boldtext" Width="60%" ForeColor="Black" GridLines="Horizontal" AllowPaging="True" CellPadding="4" BorderWidth="1px" BorderStyle="None" BorderColor="#CCCCCC" AutoGenerateColumns="False" BackColor="White" OnCancelCommand="OnCancel" OnUpdateCommand="OnSave" OnEditCommand="OnEdit">

<AlternatingItemStyle ................
<asp:BoundColumn....
<asp:BoundColumn....
<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Save" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>

</asp: datagrid>
</TR>


and this is all automatice by datagrid, because, when I click edit, it will run the code ->, refer to OnEditCommand="OnEdit" above.

public void OnEdit(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
datagrid.EditItemIndex = -1;
BindData(); }


THEN THE Save and Cancel Button are automatically appear. after click Edit Button.


Then I can change value on the Non-Readonly datagrid column, after change, when I click save, it will trigger OnSave method in my code behind.refer to OnUpdateCommand="OnSave" above.

>>>>>>
WHAT I REQUIRED ARE:- when I click Save, it will prompt out a confirmation message box. can anyone please help me?
>>>>>>
Feb 14 '07 #1
2 3457
*pressed enter early, hang on a minue for my replay.
Feb 14 '07 #2
I havent touched a datagrid in a while
But here is what i do in a gridview control
instead of using a editcommandcolumn change it to a Template and add a button along with the command name.

*The syntax is not the same for a datagrid, but you can figure it out easy in VS


Expand|Select|Wrap|Line Numbers
  1. <asp:TemplateField HeaderText="Delete">
  2. <ItemTemplate>
  3. <asp:LinkButton ID="lnlButtonDelete" runat="server" CommandName="DeleteFile"  OnClientClick="return confirm('Are you sure?')" >Delete Image</asp:LinkButton>
  4. </ItemTemplate>
  5. </asp:TemplateField>
Feb 14 '07 #3

Sign in to post your reply or Sign up for a free account.

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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.