G
Guest
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 ;
}
}
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 ;
}
}