Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 August 31st, 2010, 08:24 PM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default Just a quick Question:

I am at the end of chapter 11 right now.
I have a confusion about the contactform:
When i click the contactus either in DarkGray theme or in Monochrome i end up in Monochrome them seetings for filling out the form.
Is this suppose to b like this or am i missing something.

Tariq
 
Old September 1st, 2010, 02:15 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Maybe that page doesn't inherit BasePage in its Code Behind and Monochrome is the default theme in web.config?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 1st, 2010, 11:17 AM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default

Yes your are right Imar Monochrom is the default theme in the webconfig file, but when i changed it to the DarkGrey now the story is other way around i get the contactform in DarkGrey theme settings.
Is there any way to specify both themes at one time in web.config.

the code behind for the contactform lookis like this :
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.IO;
using System.Net.Mail;
public partial class Controls_ContactForm : System.Web.UI.UserControl
not sure where to change the inheritence.
I followed the book completely.

Tariq
 
Old September 1st, 2010, 11:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

That's the code for the User Control; how does the page that uses that control look? And can you post the code for the <pages /> element in web.config?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 1st, 2010, 02:04 PM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default

This is the code between <pages> in the web.config
Code:
<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
	<system.web>
		<pages theme="DarkGrey">
			<controls>
				<add tagPrefix="Wrox" tagName="Banner" src="~/Controls/Banner.ascx"/>
			</controls>
		</pages>
and what page you are refering to?
You mean Contact.aspx?

Last edited by tariq; September 1st, 2010 at 02:08 PM..
 
Old September 1st, 2010, 02:20 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, that looks fine. And yes, I meant Contact.aspx, if that's your page you're having problems with. As mentioned earlier, the UC is not relevant; it's the page that applies the theme.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 1st, 2010, 02:33 PM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default

This is how Contact.aspx looks:
Code:
<%@ Page Title="Contact Us" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="Contact.aspx.cs" Inherits="About_Contact" %>

<%@ Register src="../Controls/ContactForm.ascx" tagname="ContactForm" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    <uc1:ContactForm ID="ContactForm1" runat="server" />
</asp:Content>
 
Old September 1st, 2010, 02:41 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Please look at my initial reply:

Quote:
Maybe that page doesn't inherit BasePage in its Code Behind and Monochrome is the default theme in web.config?
It's the Code Behind here that's relevant. Remember the discussion in the book about the BasePage? My guess is that you didn't use your custom template for this page, or forgot to manually update the Code Behind.

Post the Code Behind so I can take a look at that.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 1st, 2010, 02:56 PM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default

This is code behind for contact.aspx, there is nothing in this file except the statdard stuff.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class About_Contact : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
and this is the code behind the Contactform.ascx(user control)
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.IO;
using System.Net.Mail;
public partial class Controls_ContactForm : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (!string.IsNullOrEmpty(PhoneHome.Text) || !string.IsNullOrEmpty(PhoneBusiness.Text))
        {
            args.IsValid = true;
        }
        else
        {
            args.IsValid = false;
        }
    }
    protected void SendButton_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            string fileName = Server.MapPath("~/App_Data/ContactForm.txt");
            string mailBody = File.ReadAllText(fileName);

            mailBody = mailBody.Replace("##Name##", Name.Text);
            mailBody = mailBody.Replace("##Email##", EmailAddress.Text);
            mailBody = mailBody.Replace("##HomePhone##", PhoneHome.Text);
            mailBody = mailBody.Replace("##BusinessPhone##", PhoneBusiness.Text);
            mailBody = mailBody.Replace("##Comments##", Comments.Text);

            MailMessage myMessage = new MailMessage();
            myMessage.Subject = "Response from web site";
            myMessage.Body = mailBody;

            myMessage.From = new MailAddress("tariq@gmail.com", "Sender : Tariq");
            myMessage.To.Add(new MailAddress("sardartariqmehmood@yahoo.com", "Receiver : Sardar"));

            SmtpClient mySmtpClient = new SmtpClient();
            mySmtpClient.Send(myMessage);

            Message.Visible = true;
            MessageSentPara.Visible = true;
            FormTable.Visible = false;
            System.Threading.Thread.Sleep(5000);
        }
    }
}
 
Old September 1st, 2010, 04:19 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
there is nothing in this file except the statdard stuff.
Which is exactly what the problem is, and what I've been trying to say from the start. Your Page does not inherit BasePage, and thus the user selected theme is not applied, but the one from the config file. Change your code to this:

public partial class About_Contact : BasePage

Refer to chanpter 6 to see what the BasePage does and how it works.

Quote:
and this is the code behind the Contactform.ascx
Don't let the UC confuse you. As I said earlier, the page is responsible for theme, not the UC; it's just part of the page and not relevant to your problem.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
tariq (September 1st, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
One quick question helovamut BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 1 March 16th, 2009 10:16 AM
Quick Question! arcadium Java GUI 1 August 5th, 2008 02:16 AM
another quick question andyhague XSLT 2 March 21st, 2006 12:13 PM
Quick Question Ben Horne Forum and Wrox.com Feedback 1 March 22nd, 2004 03:29 PM
Quick If Then Question hcweb Classic ASP Basics 2 March 13th, 2004 02:13 PM





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