How to perform this requirement
-
I am using this: btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure you want to delete?')) Test1();else return false;") my requirement is to be excute the function test1() but nothing happend and iam also trying in this manner could anyone help me Page.RegisterStartupScript("Confirm", "<script language=JavaScript>Confirm();</script>"); and in the aspx file (desiner) you need to write the following code <script language="javascript" type="text/javascript"> Function Confirm() //Sample Function { var blnConfirm = confirm("sample function to test confirm function"); if(blnConfirm == true) { alert("you have clicked yes"); return false; } else { alert("you have clicked No"); } } </script>
-
I am using this: btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure you want to delete?')) Test1();else return false;") my requirement is to be excute the function test1() but nothing happend and iam also trying in this manner could anyone help me Page.RegisterStartupScript("Confirm", "<script language=JavaScript>Confirm();</script>"); and in the aspx file (desiner) you need to write the following code <script language="javascript" type="text/javascript"> Function Confirm() //Sample Function { var blnConfirm = confirm("sample function to test confirm function"); if(blnConfirm == true) { alert("you have clicked yes"); return false; } else { alert("you have clicked No"); } } </script>
use this code
Custom ConFirm, Alert and Prompt
function FnConfirm()
{
var ans=confirm("Choose a button")
if (ans==true)
{
alert("You pressed OK");
FngoOK();
}
else
{
alert("You pressed Cancel");
FngoCancel();
}
}
function FngoOK()
{
window.location = "OK.htm";
}
function FngoCancel()
{
window.location = "Cancel.htm";
}i tried this & working. For server side you can do like this
btnDelete.Attributes.Add("onclick", "FnConfirm()")
-
I am using this: btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure you want to delete?')) Test1();else return false;") my requirement is to be excute the function test1() but nothing happend and iam also trying in this manner could anyone help me Page.RegisterStartupScript("Confirm", "<script language=JavaScript>Confirm();</script>"); and in the aspx file (desiner) you need to write the following code <script language="javascript" type="text/javascript"> Function Confirm() //Sample Function { var blnConfirm = confirm("sample function to test confirm function"); if(blnConfirm == true) { alert("you have clicked yes"); return false; } else { alert("you have clicked No"); } } </script>
Nath wrote:
Page.RegisterStartupScript("Confirm", "Confirm();");
It is unnecessary to register the confirm script since you have already included it in the page.
function Confirm() { if (confirm("Are you sure you want to delete?")) alert("Yes"); else alert("No"); }
I know the language. I've read a book. - _Madmatt
-
use this code
Custom ConFirm, Alert and Prompt
function FnConfirm()
{
var ans=confirm("Choose a button")
if (ans==true)
{
alert("You pressed OK");
FngoOK();
}
else
{
alert("You pressed Cancel");
FngoCancel();
}
}
function FngoOK()
{
window.location = "OK.htm";
}
function FngoCancel()
{
window.location = "Cancel.htm";
}i tried this & working. For server side you can do like this
btnDelete.Attributes.Add("onclick", "FnConfirm()")
thatraja wrote:
btnDelete.Attributes.Add("onclick", "FnConfirm()")
Won't work without runat=Server on the input element. Where did the OP ask about redirecting pages? and you are using far too much code to accomplish the very simple task
thatraja wrote:
var ans=confirm("Choose a button")
You are uselessly creating another variable when this is enough
if( confirm("Choose a button") ) ... else ...
I know the language. I've read a book. - _Madmatt
-
thatraja wrote:
btnDelete.Attributes.Add("onclick", "FnConfirm()")
Won't work without runat=Server on the input element. Where did the OP ask about redirecting pages? and you are using far too much code to accomplish the very simple task
thatraja wrote:
var ans=confirm("Choose a button")
You are uselessly creating another variable when this is enough
if( confirm("Choose a button") ) ... else ...
I know the language. I've read a book. - _Madmatt
|Mark Nischalke wrote 1.Won't work without runat=Server on the input element. 2.Where did the OP ask about redirecting pages? and you are using far too much code to accomplish the very simple task 3.You are uselessly creating another variable when this is enough =>1. I gave him a full HTML code and I was mentioned server side code will be like
btnDelete.Attributes.Add("onclick", "FnConfirm()")
instead of
btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure you want to delete?')) Test1();else return false;")
also it wasn't mentioned as a client control by neither me or him. =>2.Actually he called a function Test1() in his code so that i was created a 2 dummy functions for redirects based on the response for easy understand to him. =>3.Here i copied his code & made some changes & posted here so i didn't created any new variable. Happy coding :) Thanks Regards, thatraja
-
|Mark Nischalke wrote 1.Won't work without runat=Server on the input element. 2.Where did the OP ask about redirecting pages? and you are using far too much code to accomplish the very simple task 3.You are uselessly creating another variable when this is enough =>1. I gave him a full HTML code and I was mentioned server side code will be like
btnDelete.Attributes.Add("onclick", "FnConfirm()")
instead of
btnDelete.Attributes.Add("onclick", "if(confirm('Are you sure you want to delete?')) Test1();else return false;")
also it wasn't mentioned as a client control by neither me or him. =>2.Actually he called a function Test1() in his code so that i was created a 2 dummy functions for redirects based on the response for easy understand to him. =>3.Here i copied his code & made some changes & posted here so i didn't created any new variable. Happy coding :) Thanks Regards, thatraja
From your profile we can see you are not very proficient in these technologies. Perhaps do more studying before responding and answering.
thatraja wrote:
btnDelete.Attributes.Add("onclick", "FnConfirm()")
This server side code can not be be called unless the client side element has the runat=Server attribute.
thatraja wrote:
=>2.Actually he called a function Test1() in his code so that i was created a 2 dummy functions for redirects based on the response for easy understand to him.
Again, where is it stated by the OP that a redirected was needed? By added unnecessary features you may have done more to confuse than to help.
thatraja wrote:
=>3.Here i copied his code & made some changes & posted here so i didn't created any new variable.
From this we can tell you are probably very profeccient at copy and paste coding and don't fully understand what you are doing. If you knew what you where doing you should have corrected the OPs code and explained why.
I know the language. I've read a book. - _Madmatt
-
From your profile we can see you are not very proficient in these technologies. Perhaps do more studying before responding and answering.
thatraja wrote:
btnDelete.Attributes.Add("onclick", "FnConfirm()")
This server side code can not be be called unless the client side element has the runat=Server attribute.
thatraja wrote:
=>2.Actually he called a function Test1() in his code so that i was created a 2 dummy functions for redirects based on the response for easy understand to him.
Again, where is it stated by the OP that a redirected was needed? By added unnecessary features you may have done more to confuse than to help.
thatraja wrote:
=>3.Here i copied his code & made some changes & posted here so i didn't created any new variable.
From this we can tell you are probably very profeccient at copy and paste coding and don't fully understand what you are doing. If you knew what you where doing you should have corrected the OPs code and explained why.
I know the language. I've read a book. - _Madmatt
You are right mate, still didn't completed my Master degree & i hope it will take a year to complete. And now i'm started to studying in latest things in those technologies so that i joined also Codeproject this month which is nice. |Mark Nischalke wrote This server side code can not be be called unless the client side element has the runat=Server attribute. but here the btnDelete is a server side element so that i was added the attribute in runtime. Again, where is it stated by the OP that a redirected was needed? By added unnecessary features you may have done more to confuse than to help. I accept this one my mistake because i didn't thought about his confusion by the redirection code. It would be better if i put those alert messages instead of redirections inside those dummy functions. **From this we can tell you are probably very proficient at copy and paste coding and don't fully understand what you are doing. If you knew what you where doing you should have corrected the OPs code and explained why.**Actually already he was posted some sample code which has some issue. But i thought it would be better to make some changes in that code instead of writing an new one because he may be confuse here too. Also i have waited for his response. That's all. Thanks for your feedback Mate can you help me for my study by preferring things in technologies. Also i have visited your profile page but your blog isn't write mode for me. how to contact you? Please help. Thanks. :)
-
use this code
Custom ConFirm, Alert and Prompt
function FnConfirm()
{
var ans=confirm("Choose a button")
if (ans==true)
{
alert("You pressed OK");
FngoOK();
}
else
{
alert("You pressed Cancel");
FngoCancel();
}
}
function FngoOK()
{
window.location = "OK.htm";
}
function FngoCancel()
{
window.location = "Cancel.htm";
}i tried this & working. For server side you can do like this
btnDelete.Attributes.Add("onclick", "FnConfirm()")
Thanks for your help and i was to new to work with javascript and if user clicks on ok then i have to redirect to another page that is happening if on cancel then i have to focus him on a text control. I will try for that. once again very thanks for your help
-
Thanks for your help and i was to new to work with javascript and if user clicks on ok then i have to redirect to another page that is happening if on cancel then i have to focus him on a text control. I will try for that. once again very thanks for your help
use the following script
function FnConfirm()
{
if (confirm("Choose a button"))
{
window.location = "anotherpage.htm";//If OK button pressed
}
else
{
document.getElementById('anothertextbox').focus();//If Cancel button pressed
}
}Here 'anothertextbox' is the name of your another textbox.
-
You are right mate, still didn't completed my Master degree & i hope it will take a year to complete. And now i'm started to studying in latest things in those technologies so that i joined also Codeproject this month which is nice. |Mark Nischalke wrote This server side code can not be be called unless the client side element has the runat=Server attribute. but here the btnDelete is a server side element so that i was added the attribute in runtime. Again, where is it stated by the OP that a redirected was needed? By added unnecessary features you may have done more to confuse than to help. I accept this one my mistake because i didn't thought about his confusion by the redirection code. It would be better if i put those alert messages instead of redirections inside those dummy functions. **From this we can tell you are probably very proficient at copy and paste coding and don't fully understand what you are doing. If you knew what you where doing you should have corrected the OPs code and explained why.**Actually already he was posted some sample code which has some issue. But i thought it would be better to make some changes in that code instead of writing an new one because he may be confuse here too. Also i have waited for his response. That's all. Thanks for your feedback Mate can you help me for my study by preferring things in technologies. Also i have visited your profile page but your blog isn't write mode for me. how to contact you? Please help. Thanks. :)
I cant get you what you have studied if you are going to assist me in learning technology i would be greatful and my mail id is mca.nath@gmail.com you can contact me through this maild Thanks & Regards, K. Amarnath.