Javascript confirmation in asp.net
-
Hi, I have used javascript confirmation on button click.On button click confirmation message pop up correctly. I have "update()" and "addnew()" function calls in button click event,If user click button confirmation message should get pop up and on confirmation "update()" function should get called else "AddNew()" function should get called. I hope someone know solution plz share ur idea with me. Thanks, Nagraj.
-
Hi, I have used javascript confirmation on button click.On button click confirmation message pop up correctly. I have "update()" and "addnew()" function calls in button click event,If user click button confirmation message should get pop up and on confirmation "update()" function should get called else "AddNew()" function should get called. I hope someone know solution plz share ur idea with me. Thanks, Nagraj.
Response.Write( "" + " function showAchPendingMsg() { " + " var pendingConfirmation = window.confirm('PG');" + " if (pendingConfirmation == true) { ShowDetail()"+ " } else { DoShow()"+ " " + " } " + " }" + " showAchPendingMsg();" + " function DoShow() { alert('else');}"+ " function ShowDetail() { alert('if');}"+ "<" + "/" + "script>"); </x-turndown>
-
Response.Write( "" + " function showAchPendingMsg() { " + " var pendingConfirmation = window.confirm('PG');" + " if (pendingConfirmation == true) { ShowDetail()"+ " } else { DoShow()"+ " " + " } " + " }" + " showAchPendingMsg();" + " function DoShow() { alert('else');}"+ " function ShowDetail() { alert('if');}"+ "<" + "/" + "script>"); </x-turndown>
RegisterClientScriptBlock is better, and you didn't show him how to hook the call into his click event, either.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
RegisterClientScriptBlock is better, and you didn't show him how to hook the call into his click event, either.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Is this the code wot u were talking about ? If yes will u plz lemme know why it is better? string scriptString =( "" + " function showAchPendingMsg() { " + " var pendingConfirmation = window.confirm('PG');" + " if (pendingConfirmation == true) { ShowDetail()"+ " } else { DoShow()"+ " " + " } " + " }" + " showAchPendingMsg();" + " function DoShow() { alert('else');}"+ " function ShowDetail() { alert('if');}"+ "<" + "/" + "script>"); string scriptName = "Confirm"; if(!Page.IsClientScriptBlockRegistered(scriptName);) { Page.RegisterClientScriptBlock(scriptName,scriptString); } </x-turndown>
-
Is this the code wot u were talking about ? If yes will u plz lemme know why it is better? string scriptString =( "" + " function showAchPendingMsg() { " + " var pendingConfirmation = window.confirm('PG');" + " if (pendingConfirmation == true) { ShowDetail()"+ " } else { DoShow()"+ " " + " } " + " }" + " showAchPendingMsg();" + " function DoShow() { alert('else');}"+ " function ShowDetail() { alert('if');}"+ "<" + "/" + "script>"); string scriptName = "Confirm"; if(!Page.IsClientScriptBlockRegistered(scriptName);) { Page.RegisterClientScriptBlock(scriptName,scriptString); } </x-turndown>
He is telling instead of using Response.Write to send JS script, use RegisterClientScript which is in page object.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
He is telling instead of using Response.Write to send JS script, use RegisterClientScript which is in page object.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
Yeah I understood.. But now I just want to know how it is better.. what is the utility of it.
What did you exactly tried to do with the
Response.Write
method? Let me say that clearly - You tried toRegister blocks of client-side script containing functions
. Microsoft has provide a method very specific to perform this particular task'RegisterClientScriptBlock'
.Response.write
Method is meant for writting a specified string to the current HTTP output. The specified string can be a Dynamically Build Javascript Code. But it's wellsuitable
for aJavascript Alert message
when we try to write Javascript code on the client using Response.Write(), Not for Registering blocks of client-side script containing functions. There are many ways to solve a problem. The question is Are we doing it the right way, the best way?- Regards -
JON
Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
-
What did you exactly tried to do with the
Response.Write
method? Let me say that clearly - You tried toRegister blocks of client-side script containing functions
. Microsoft has provide a method very specific to perform this particular task'RegisterClientScriptBlock'
.Response.write
Method is meant for writting a specified string to the current HTTP output. The specified string can be a Dynamically Build Javascript Code. But it's wellsuitable
for aJavascript Alert message
when we try to write Javascript code on the client using Response.Write(), Not for Registering blocks of client-side script containing functions. There are many ways to solve a problem. The question is Are we doing it the right way, the best way?- Regards -
JON
Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
This is not the exact difference.
Response.Write()
places the string (in this case dynamic JS code) supplied on the top of the page, that is outside HTML tag. But using the specified methods to emit client script ensures that it is inside the DOM. You can use eitherRegisterClientScriptBlock()
orRegisterStartupScript()
for injecting JS code to the page. More over,RegisterStartupScript()
executes before the page'sOnLoad()
event fires.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
This is not the exact difference.
Response.Write()
places the string (in this case dynamic JS code) supplied on the top of the page, that is outside HTML tag. But using the specified methods to emit client script ensures that it is inside the DOM. You can use eitherRegisterClientScriptBlock()
orRegisterStartupScript()
for injecting JS code to the page. More over,RegisterStartupScript()
executes before the page'sOnLoad()
event fires.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
This is not the exact difference.
Response.Write()
places the string (in this case dynamic JS code) supplied on the top of the page, that is outside HTML tag. But using the specified methods to emit client script ensures that it is inside the DOM. You can use eitherRegisterClientScriptBlock()
orRegisterStartupScript()
for injecting JS code to the page. More over,RegisterStartupScript()
executes before the page'sOnLoad()
event fires.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
N a v a n e e t h wrote:
This is not the exact difference
Did I explain about the Differences? I guess No. I tried to compare with what Prateek did with Response.Write() and What Could have been done.
- Regards -
JON
Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
-
N a v a n e e t h wrote:
This is not the exact difference
Did I explain about the Differences? I guess No. I tried to compare with what Prateek did with Response.Write() and What Could have been done.
- Regards -
JON
Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
John Prabhu wrote:
Did I explain about the Differences?
He was asking about why use client script methods to register instead of Response.Write. But your answer was not fully explaining. So I guessed you were comparing Response.Write and the other and given my reply.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions