Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 15th, 2009, 01:04 AM
Authorized User
 
Join Date: Feb 2009
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default DB Connection To WebConfig n Message Box

2 questions here.

1) How to write code to call DB connection stored in the webconfig file in a codepage under ASP.Net 3.5?

2) How to write a message box alert under a button event to prompt at client?

Appreciate if there is any example to show the above.

thanks
  #2 (permalink)  
Old February 15th, 2009, 03:14 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

1)

Assuming your connection string in web.config is called "myConnectionString"

Code:
System.Web.Configuration.WebConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString
2)

Code:
<asp:Button ID="btnDelete" runat="server" Text="Delete" OnClientClick="return (confirm('Are you sure you want to delete this item?'));" />
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #3 (permalink)  
Old February 15th, 2009, 09:19 PM
Authorized User
 
Join Date: Feb 2009
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Lee Dumond View Post
1)

Assuming your connection string in web.config is called "myConnectionString"

Code:
System.Web.Configuration.WebConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString
2)

Code:
<asp:Button ID="btnDelete" runat="server" Text="Delete" OnClientClick="return (confirm('Are you sure you want to delete this item?'));" />
Thanks for the advice. However, there are still some errors appear in the coding as shown in the red square box below

1)
http://i206.photobucket.com/albums/b...WebConfig1.jpg

http://i206.photobucket.com/albums/b...ctionError.jpg

Last edited by cheer; February 15th, 2009 at 09:23 PM..
  #4 (permalink)  
Old February 15th, 2009, 09:42 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

If you're using VB, you would want to use ( ) instead of [ ] there.

Code:
System.Web.Configuration.WebConfigurationManager.ConnectionStrings("oqConnectionString").ConnectionString
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #5 (permalink)  
Old February 15th, 2009, 11:08 PM
Authorized User
 
Join Date: Feb 2009
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Lee Dumond View Post
If you're using VB, you would want to use ( ) instead of [ ] there.

Code:
System.Web.Configuration.WebConfigurationManager.ConnectionStrings("oqConnectionString").ConnectionString
<asp:Button ID="btnDelete" runat="server" Text="Delete" OnClientClick="return (confirm('Are you sure you want to delete this item?'));" />

How to convert this to the VB?
  #6 (permalink)  
Old February 15th, 2009, 11:23 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

That second example is server control markup with JavaScript, so that should work with any language.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #7 (permalink)  
Old February 16th, 2009, 12:06 AM
Authorized User
 
Join Date: Feb 2009
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Lee Dumond View Post
That second example is server control markup with JavaScript, so that should work with any language.
Thanks. How to call a VB written function under the XXX.ASPX.VB from the javascript?
  #8 (permalink)  
Old February 16th, 2009, 12:17 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Your original question was about how to raise a messagebox alert on the client, wasn't it?

Anyway, if you have a VB function that runs on the server, you would call the function from the OnClick event instead of the OnClientClick event. Just like you have probably done a thousand times. That is pretty much the basic functionality of a button.

Umm. maybe you could tell us what you are trying to do, and we could point you in the right direction?
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
The Following User Says Thank You to Lee Dumond For This Useful Post:
cheer (February 16th, 2009)
  #9 (permalink)  
Old February 16th, 2009, 12:23 AM
Authorized User
 
Join Date: Feb 2009
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Lee Dumond View Post
Your original question was about how to raise a messagebox alert on the client, wasn't it?

Anyway, if you have a VB function that runs on the server, you would call the function from the OnClick event instead of the OnClientClick event. Just like you have probably done a thousand times. That is pretty much the basic functionality of a button.

Umm. maybe you could tell us what you are trying to do, and we could point you in the right direction?
Thanks, you have answered my question.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Message box basie Classic ASP Basics 1 September 4th, 2008 01:09 PM
how to use message box? andy hee ASP.NET 1.0 and 1.1 Basics 1 April 18th, 2006 04:53 AM
message box nalla ASP.NET 2.0 Professional 4 December 23rd, 2005 03:00 AM
Message Box HELP!!! Dwizz ASP.NET 1.0 and 1.1 Basics 1 July 21st, 2005 07:22 AM



All times are GMT -4. The time now is 10:45 PM.


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