467,895 Members | 1,414 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,895 developers. It's quick & easy.

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
  • viewed: 3237
Share:
2 Replies
chazcross
*pressed enter early, hang on a minue for my replay.
Feb 14 '07 #2
chazcross
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

Post your reply

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

Similar topics

7 posts views Thread by Julia Briggs | last post: by
5 posts views Thread by Krishna | last post: by
1 post views Thread by desmcc | last post: by
4 posts views Thread by Martin Feuersteiner | last post: by
13 posts views Thread by ukrbend | last post: by
5 posts views Thread by Newbie Coder | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.