473,320 Members | 2,003 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,320 software developers and data experts.

ASP NET and javascript - urgent

Hi...


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>


I have a Edit, Save, Cancel command on my datagrid, when click Save, -> OnUpdateCommand="save_data",

the save_data function located in test.aspx.cs, code behind,

I don't want directly save my data, I plan to insert the javascript function above to the save_data function, so I need to call the javascript from code behind



Example: In test.aspx.cs

I have a function

public void save_data(){

------------ CAN I CALL A JAVASCRIPT HERE?

}


anyone please help
Feb 13 '07 #1
2 905
hi,
use the below code in the pageload event
Dim button As WebControl
button = Page.findControl("btnsave")
button.Attributes.Add("onclick", "return confirm_save (this.form);")

in the javascript
function confirm_save (frm)
{
return confirm ('Are you sure you want to Save the record?')
}
Feb 13 '07 #2
But this is a button in edit template datagrid

save and cancel only appear after edit button clicked on datagrid..

where can find a save and cancel button name?

this is not a link button, or web button


hi,
use the below code in the pageload event
Dim button As WebControl
button = Page.findControl("btnsave")
button.Attributes.Add("onclick", "return confirm_save (this.form);")

in the javascript
function confirm_save (frm)
{
return confirm ('Are you sure you want to Save the record?')
}
Feb 13 '07 #3

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

Similar topics

5
by: Alex Maghen | last post by:
I frequently find myself wanting to insert some basic client-side JavaScript functions in the page of an ASPX of mine. But I find it so frustrating that I have to actually contruct my JavaScript in...
3
by: reachnaveenkumar | last post by:
Hi, Can any one give me code to find out the height and width of a textbox in Javascript? Its very urgent. Thank you, regards Naveen
5
by: Jason | last post by:
Hi, I have some simple JavaScript on my page that worked for years in IE 6 without an error that I am aware of, but does not work in IE 7. Any insight on this issue that anyone can provide would...
1
by: gregalliance | last post by:
m retriving a variable's value which is in javascript into an function in asp,but asp is not able to read dat variable's value,plz direct me for it,its urgent for ma project work.
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
7
by: PhilTheGap | last post by:
Hi, I've tried this: <asp:Button ID="Save" runat="server" Text="OK" OnClick="ServerSave" OnClientClick="SaveParam (<% Util.MaxTags %>)" /> but if fails... Util is a C# class, MaxTags a...
9
by: Oriane | last post by:
Hi, I can set a breakpoint in my javascript client side code, but as sson as I start the Ajax Asp.Net application in debug mode, an exlamation mark shows up on the breakpoint, and a tooltip...
20
by: Peter | last post by:
I need a popup alert after a post back. 1) user clicks on the submit button 2) Server side code runs and if the result is false I want to display a java script alert("It did not work") How to...
7
by: Peter | last post by:
I have a HoverMenuExtender which contains an asp:PlaceHolder, this place holder has a User Control and this control contrains a Button. The problem I am having is after the button fires the click...
4
by: Peter | last post by:
I have a DataList and each item in the datalist has an imge, I want to change the datalist item image on the client side when user clicks a button. How would I do that with JavaScript, does anyone...
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...
1
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: 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)...
0
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
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.