Question

asp.net master page w/vb code not working

Asked by: dcmense

Hi,

I a newbie, so please be kind. :)

I have a asp.net application that is working just fine before I attempted to integrate it into a asp master page.  I have attached the original default.aspx and default.aspx.vb and these files work as desired (the files are attached as OriginalDefault.aspx.txt and OriginalDefault.aspx.vb.txt).  What they do is take input from a form and adds the information to a MySQL database and then send an email.

What I attempting to do is create a asp master page of the original default.aspx file with a contentplaceholder section (handymansuccess.master is the master).  I then created a new default.aspx file using handymansuccess.master as the master file.  Everything in the new default displays just fine, but the vb code does not seem to be working.  It does not add the information to the database, nor does it send the email.

I would appreciate any help understanding and correcting the apparent mistake that I have made in creating the master page, the associated default.asp, and the code behind file.  I'm learning how to do this and any additional guidance would be very much appreciated.  I have attached the file mentioned above for reference.

Thanks a bunch!

Brian

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-06-09 at 09:53:24ID24476464
Topics

Expression Web

,

Programming for ASP.NET

,

Miscellaneous Web Development

Participating Experts
1
Points
500
Comments
17

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ASP.NET
    I currently have Dreamweaver 3 (on a Mac), but am going to have to learn ASP.net for a client's Web site. What do I need? Can I do this with Dreamweaver MX on a Mac? Or MUST it be a PC? Also, what are my needs for the database end of things (i.e., for the testing of the p...
  2. ASP.NET and MySQL
    hello all :) Quite a simple question for you .net veterans. I am looking to move from classic asp to asp.net, and after working through a few basic tutorials I really like the say it works. Naturally I am using the language I know best, Vb, and now I want to sue the databa...
  3. MySql with asp.net
    Hello, so I have looked at a tutorial and setup mysql so that it works with asp.net. http://www.stardeveloper.com/articles/display.html?article=2003052201&page=1 however, what I want to do is to use .sql files in my c# code for an asp.net application. For example, ca...
  4. Web Language Guidance
    I am a Novice programmer with no formal programming training except Cobal, Fortran and RPG xx years ago, looking for some guidance on web language selection. I do have a strong grip on programming with the .net platform but only in client/server and DCOM apps. I am going to...
  5. I am a newbie in asp.net
    Hi, I am a newbie in asp.net and currently i need to create a DVD sales site together with my friends. My part in the project is using SQL server & asp.net. I need to create log in page with a link to allow new user to register in a membership page with form include the...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: prairiedogPosted on 2009-06-09 at 10:01:53ID: 24583186

After creating the new default.aspx, did you delete or exclude the old one?

 

by: prairiedogPosted on 2009-06-09 at 10:02:17ID: 24583189

Is the new one called "Default.aspx" or some other name?

 

by: dcmensePosted on 2009-06-09 at 10:49:23ID: 24583683

prairiedog,

I renamed the file default.aspx to OriginalDefault.aspx on the server.  So when the page loads it should be loading the correct file, default.aspx.

Thanks for he assistance,
Brian

 

by: prairiedogPosted on 2009-06-09 at 10:56:04ID: 24583760

You will also need to rename the class name. Open up originaldefault.vb and you will see a line at the top of the page says: Partial Class _Default, change "_Default" to OriginalDefault.

Then open originaldefault.aspx in HTML mode, at the very top of the page where says CodeFile="Default.aspx.vb", change it to CodeFile="originaldefault.aspx.vb".

Run your code again to see if it works.

 

by: dcmensePosted on 2009-06-09 at 12:01:03ID: 24584450

prairedog,

Thanks, however the one I'm trying to make work is the new default and the associated code behind file that are based on the master page.  In other words, I'm trying to get default.aspx and default.aspx.vb working.  I provided the original files as a reference to help others help me.  Sorry about any confusion.

Brian

 

by: prairiedogPosted on 2009-06-09 at 12:10:46ID: 24584565

I understood your problem.

Since you kept the old default page, and its class name is also call "partial class _Default", which means you have two classes with the exactly same name in your application. It might be the problem, because the new default.aspx does not know which class to call to. If you don't want to change those names, then you can temporarily exclude them from yoru project and then run your application to see if ti works.

 

by: dcmensePosted on 2009-06-09 at 12:51:15ID: 24585008

Becuase I only want to use the new default.aspx file based on the master page, I deleted the old, original, versions from the directory.  Now I only have default.aspx, default.aspx.vb and the masterfile file in the directory.  Thes files match the two file I uploaded ealier, default.aspx(.txt) and default.aspx.vb(.txt).  I added the extension txt to allow the files to upload.

Now I believe I only have one class named '_Defualt' in the code behind file default.aspx.vb.  With this change I get the same results as articulated earlier.  The database does not update nor is any email sent.  When the submit button is clicked I get the message "Sorry, an error occured. Please try again later."

P.S.  I'll be leaving shortly, so it will be later tonight or tomorrow morning before I can check back in.  Thanks for the help.  I will try to check right before I leave.  

 

by: prairiedogPosted on 2009-06-09 at 13:00:03ID: 24585096

It looks like that an exception ocurred while trying to send email. Change your try/catch block as follows:


Try
           body = String.Format("New Registration: " + System.Environment.NewLine + _
                            OptInName.Text + ", " + OptInEmailAddress.Text)
            Dim toAddress As String = OptInEmailAddress.Text
           'email = New MailMessage("email@address.com", toAddress, "New Registration", body)
           email = New MailMessage("email@address.com", toAddress, "New Registration", body)
           email.Attachments.Add(New Attachment(Server.MapPath("/attachment.txt")))
           smtp.Credentials = CredentialCache.DefaultNetworkCredentials
           smtp.Send(email)
            AddRegistrationToDB(OptInName.Text, OptInEmailAddress.Text)
           Response.Redirect("ThankYou.aspx")
 Catch ex1 As System.Threadign.ThreadAbortException
       Catch ex As Exception
           'Temporarily remove lines so that we can see the error message.
      End Try

I added another Catch because Response.Redirect will also generate an exception, but we don't need to worry about that exception.

Re-run your app and post the error message.

 

by: dcmensePosted on 2009-06-09 at 13:15:17ID: 24585258

Ok, I changed it accordingly.  When I entered the information it simply 'refreshed' the screen.  Leaving what I typed into the fields and showed no error message.  I checked the database and no new entry nor was the email delivered.

Here is what I have in the default.aspx.vb file...

            Response.Redirect("ThankYou.aspx")
      Catch ex1 As System.Threading.ThreadAbortException
        Catch ex As Exception
'            lblMessage.Visible = True
'            lblMessage.Text = "Sorry, an error occurred.  Please try again later."
        End Try

 

by: prairiedogPosted on 2009-06-09 at 13:19:35ID: 24585292

Strange.

Put a break point on the button's click event handler and then step into your app to see what is happening.

 

by: dcmensePosted on 2009-06-09 at 13:38:54ID: 24585510

Prairiedog,

I would set the break point if I could.  I have created this code on my pc and I upload this to my server.  

The part of this that is truely strange is that if I place the original versions of default and the leave the same code behind file, default.aspx.vb, it works just fine.  It was only when I created the master page and then created the new default from the master file that this stopped working.

Based on the chain of events I think the default.aspx file is where something is messed up.

Thanks!
Brian

 

by: prairiedogPosted on 2009-06-09 at 13:44:55ID: 24585592

>>>I have created this code on my pc and I upload this to my server.

Did the app work on your own pc?

 

by: dcmensePosted on 2009-06-09 at 20:09:55ID: 24587733

I do not have MySQL installed on my pc so I'm not able to test it on my pc.  I'm literally creating the file locally and then uploading it to the server for testing.

 

by: prairiedogPosted on 2009-06-09 at 20:15:50ID: 24587754

1. How do you upload?

2. A dummy question, did you compile the site before uploading?

 

by: prairiedogPosted on 2009-06-09 at 20:59:03ID: 24587876

My bad. In your second Catch block, you need to add this line of code to see the actual error message:

Throw ex

Catch ex1 As System.Threading.ThreadAbortException
        Catch ex As Exception
          Throw ex
'            lblMessage.Visible = True
'            lblMessage.Text = "Sorry, an error occurred.  Please try again later."
        End Try

                                              
1:
2:
3:
4:
5:
6:

Select allOpen in new window

 

by: dcmensePosted on 2009-06-09 at 21:33:53ID: 24587995

prairiedog,

In a fit of despration, I deleted the entire directory on the server and recopied all the files to the server.  Something must have been corrupted as it all works fine now.  This is really strange.

I guess the moral of this situation is when nothing makes much sense, delete and restart!

Because of you quick and continued responses to my posts I'm going to mark your last message as the solution.  You do deserve it!

Thanks,
Brian

 

by: prairiedogPosted on 2009-06-10 at 04:54:18ID: 24590247

It seems that your app on the production server was still using the old dll after you add the new page. It happens sometime and that is why I asked the dummy question before if you compile your app before uploading it.

In the future, under "Build" menu, there is an option called "Clean Solution" which will delete the old dll's from bin folder and create new ones.

Also, it will be better if you can test your app on your local machine first, then deploy to the production server, so you should install MySQL on your pc.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...