Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 13th, 2004, 08:23 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default RegisterStartupScript - Postback from script

I am developing in ASP.NET and have come across a problem: I need to prompt the user with a yes / no question, which I am doing by inserting a window.confirm() script into a RegisterStartupScript command(), as this needs to be done from a server-side function. The script also writes to a hidden control whether the the user clicked on OK or cancel.

This works fine, but I need a postback to occur after the user has clicked OK so that I can carry out the process the user was prompted for. Otherwise there is no way the code can respond to this event. Any Ideas?

Thanks for your help,
Gary

 
Old April 13th, 2004, 01:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Are you adding the event attribute to the button? For example:

btnButtonName.Attributes.Add("onclick", "return (confirm('Are you sure you want to process this?'));")

J
 
Old April 13th, 2004, 08:06 PM
Authorized User
 
Join Date: Mar 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not so sure what you're gonna to do with your programme, but does this script helps?

Dim str as string = "if(confirm("Are you sure")){---your 'OK' statement---;}else{---your cancel statement---;}"

Page.RegisterStartupScript("str", str)

 
Old April 14th, 2004, 02:54 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your comments, however I got round the problem by
writing some script to take the value from the confirm box and enter it into the address bar parameters.

<script language=javascript>
var con = confirm("Click yes to postback"); if(con)window.location="mywebpage.aspx?clicked=OK" ;
</script>

Cheers,
Gary

 
Old April 14th, 2004, 05:12 AM
Authorized User
 
Join Date: Mar 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i still not so sure what you really want to do with your program. can you please show me some codes or the error message? Btw, your code looks fine to me






Similar Threads
Thread Thread Starter Forum Replies Last Post
Page.RegisterStartupScript shanwaj ASP.NET 2.0 Basics 4 October 6th, 2008 01:46 AM
Page.ClientScript.RegisterStartupScript & Threads VerbatimBOT ASP.NET 2.0 Professional 0 July 23rd, 2008 05:39 AM
Problem calling RegisterStartupScript. KalpanaT ASP.NET 1.0 and 1.1 Basics 1 January 14th, 2008 03:52 AM
Postback from client script gp_mk HTML Code Clinic 2 April 14th, 2004 02:48 AM
Call and run CGI script from a PHP script ... how? dbruins BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 June 10th, 2003 03:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.