i have a c# asp.net webform that has a "Close" button. When the user clicks
the Close button, a message box saying "do u want to save to database...?".
the problem is that the statements inside the Close function are not being
executed. how can i save the data in the webform to the database? can i show
a message box without using javascript? can i call a function defined in the
code behind from within javascript? thanks in advance.
code behind:
private void Page_Load(object sender, System.EventArgs e)
{
//btnClose.Attributes.Add("OnClick", "javascript:Close()");
btnClose.Attributes.Add("OnMouseDown", "javascript:Close()");
.......
}
private void btnClose_Click(object sender, System.EventArgs e)
{
if (txtClose.Text == "1")
{
InsertToDatabase();
}
Response.Redirect("taskOrderSummary.aspx");
}
html code in aspx page:
<script type="text/javascript">
function Close(){
var agree=confirm("Do you wish to save changes?");
if (agree)
{
document.Form1.txtClose.value = 1 ;
}
else
{
document.Form1.txtClose.value = 0 ;
}
} 2 4032
i recomend to doit so...
private void Page_Load(object sender, System.EventArgs e)
{
btnClose.Attributes.Add("OnClick", "javascript :return Close()");
.......
}
function Close(){
return confirm("Do you wish to save changes?");
}
ps: i think you have the handler declaration for the click button in the
behind code...
"Newbie" wrote: i have a c# asp.net webform that has a "Close" button. When the user clicks the Close button, a message box saying "do u want to save to database...?". the problem is that the statements inside the Close function are not being executed. how can i save the data in the webform to the database? can i show a message box without using javascript? can i call a function defined in the code behind from within javascript? thanks in advance.
code behind: private void Page_Load(object sender, System.EventArgs e) { //btnClose.Attributes.Add("OnClick", "javascript:Close()"); btnClose.Attributes.Add("OnMouseDown", "javascript:Close()"); ....... }
private void btnClose_Click(object sender, System.EventArgs e) { if (txtClose.Text == "1") {
InsertToDatabase(); } Response.Redirect("taskOrderSummary.aspx"); }
html code in aspx page: <script type="text/javascript"> function Close(){ var agree=confirm("Do you wish to save changes?"); if (agree) { document.Form1.txtClose.value = 1 ; } else { document.Form1.txtClose.value = 0 ; } }
i recomend to doit so...
private void Page_Load(object sender, System.EventArgs e)
{
btnClose.Attributes.Add("OnClick", "javascript :return Close()");
.......
}
function Close(){
return confirm("Do you wish to save changes?");
}
ps: i think you have the handler declaration for the click button in the
behind code...
"Newbie" wrote: i have a c# asp.net webform that has a "Close" button. When the user clicks the Close button, a message box saying "do u want to save to database...?". the problem is that the statements inside the Close function are not being executed. how can i save the data in the webform to the database? can i show a message box without using javascript? can i call a function defined in the code behind from within javascript? thanks in advance.
code behind: private void Page_Load(object sender, System.EventArgs e) { //btnClose.Attributes.Add("OnClick", "javascript:Close()"); btnClose.Attributes.Add("OnMouseDown", "javascript:Close()"); ....... }
private void btnClose_Click(object sender, System.EventArgs e) { if (txtClose.Text == "1") {
InsertToDatabase(); } Response.Redirect("taskOrderSummary.aspx"); }
html code in aspx page: <script type="text/javascript"> function Close(){ var agree=confirm("Do you wish to save changes?"); if (agree) { document.Form1.txtClose.value = 1 ; } else { document.Form1.txtClose.value = 0 ; } } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: yfng |
last post by:
In a web form, I want the user clicks on one button and this button will
trigger another button/link which will open a new browser window? How to do
that? Is there any method like...
|
by: Jason Kyle Baginski |
last post by:
Here's a little test app to demonstrate a problem I'm having.
It creates four buttons, each one with the different FlatStyle types
available. Three of them behave exactly the same way(and the...
|
by: Olav Tollefsen |
last post by:
I have a rather fundamental ASP.NET question.
On my page I have a search text box for user input, a button (which invokes
a event handler on the page) and a user control to display the results....
|
by: Russell |
last post by:
I have a web page that i am using an image button as my submit button. The
code behind the button works, but when I click enter on the web page,
nothing happens. Can anybody tell me how to get my...
|
by: Shimon Sim |
last post by:
I put linkbutton in a repeater header. I attached event handler in makeup as
onclick="btnSort_Click".
Made btnSort_Click method public. It doesn't fire if I click on it. I tried
to attach it in...
|
by: MgGuigg |
last post by:
Hello all, This is my first time posting a question to this forum, so here is
hoping I am following protocol. I am scraping the rust off my old Basic
programming skills, and have just recently...
|
by: Gary Paris |
last post by:
On my windowsform, I have a tab control. On the control, I have as button
called btnSave. I wanted to move the button off the tab control and onto
the windowsform. Shouldn't be a problem I...
|
by: Ben |
last post by:
Hello
I have frames set up in an asp.net application and need one frame to refresh
another. Seeing as events need to be registered at the time the page is sent
from the server, I was wondering...
|
by: Joseph Geretz |
last post by:
I'm porting a C# Outlook Addin originally engineered as a COM Addin over to
use VSTO. I've gotten this to the point where my VSTO Addin installs its
Menu items and Toolbar buttons when Outlook...
|
by: AE_Cory |
last post by:
I'm a n00b to Visual C++ and OOP, but not to programming in general.
Here's the problem: Not knowing what I'm doing, I've made my VC++
application as a CLR Window Forms project. Now, I have a...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
| |