Nfurman 0 Junior Poster in Training

Hello again.

Default.aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class contact : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        State.Enabled = false;
        ShowCaptchaNums();
    }

    protected void Country_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (Country.Text == "United States")
        {
            State.Enabled = true;
        }
        else
        {
            State.Enabled = false;
        }
    }

    protected int GenerateFirstNum()
    {
        int firstNum; 
        Random rand = new Random();
        firstNum=rand.Next(4);
        return firstNum;
    }

    protected int GenerateSecondNum()
    {
        int secondNum;
        Random rand = new Random();
        secondNum = rand.Next(5);
        return secondNum;
    }

    protected void ShowCaptchaNums()
    {
        lblFirstNum.Text = GenerateFirstNum().ToString();
        lblSecondNum.Text = GenerateSecondNum().ToString();
    }
    protected void btnClear_Click(object sender, EventArgs e)
    {
        tbAddressLine1.Text = String.Empty;
        tbAddressLine2.Text = String.Empty;
        Country.Text = String.Empty;
        State.Text = String.Empty;
        tbCompany.Text = String.Empty;
        tbEmail.Text = String.Empty;
        tbMessage.Text = String.Empty;
        tbName.Text = String.Empty;
        tbPhone.Text = String.Empty;
    }

    protected void ChangePanelHeight
    {
        
    }
}
<%@ Page Title="Contact Us" Language="C#" MasterPageFile="~/MainPage.master" AutoEventWireup="true" CodeFile="contact.aspx.cs" Inherits="contact" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .style2
        {
            width: 575px;
        }
        .style3
        {
        width: 153px;
    }
    </style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainData" Runat="Server">
    <table align="center" cellpadding="2" class="style2">
        <tr>
            <td class="style3">
                Name: *</td>
            <td>
                <asp:TextBox ID="tbName" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="tbName" ErrorMessage="&gt; Required Field."></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style3">
                Company:</td>
            <td>
                <asp:TextBox ID="tbCompany" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style3">
                Email: *</td>
            <td>
                <asp:TextBox ID="tbEmail" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ControlToValidate="tbEmail" ErrorMessage="&gt; Required Field"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                    ControlToValidate="tbEmail" ErrorMessage="Wrong Email Format" 
                    SetFocusOnError="True" 
                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td class="style3">
                Phone: *</td>
            <td>
                <asp:TextBox ID="tbPhone" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                    ControlToValidate="tbPhone" Display="Dynamic" ErrorMessage="&gt; RequiredField"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                    ControlToValidate="tbPhone" ErrorMessage="&gt; Only 0-9 ,+ Signs are allowed"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td class="style3">
                Address Line #1:</td>
            <td>
                <asp:TextBox ID="tbAddressLine1" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style3">
                Address Line #2:</td>
            <td>
                <asp:TextBox ID="tbAddressLine2" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style3">
                Country: *</td>
            <td>
                <asp:DropDownList ID="Country" runat="server" AutoPostBack="True" 
                                        Font-Names="Trebuchet MS"
                     onselectedindexchanged="Country_SelectedIndexChanged">
                                        <asp:ListItem Selected="True" Value="">Select One</asp:ListItem>
                                        <asp:ListItem>Afghanistan</asp:ListItem>
                                       // bla bla bla
                                        <asp:ListItem>Zimbabwe</asp:ListItem>
                                    </asp:DropDownList>
            &nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                    ControlToValidate="Country" ErrorMessage="&gt; RequiredField"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style3">
                State:</td>
            <td>
                <asp:DropDownList ID="State" runat="server" Font-Names="Trebuchet MS" 
                                         
                                        ToolTip="Optional field. Select your state if you are located in U.S.">
                                        <asp:ListItem Selected="True" Value="">Select One</asp:ListItem>
                                        <asp:ListItem>Alabama</asp:ListItem>
                                       // bla bla again
                                        <asp:ListItem>Wyoming</asp:ListItem>
                                    </asp:DropDownList>
            &nbsp;U.S Only.</td>
        </tr>
        <tr>
            <td class="style3" valign="top">
                Message: *<br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                    ControlToValidate="tbMessage" ErrorMessage="RequiredField &gt;"></asp:RequiredFieldValidator>
            </td>
            <td>
                <asp:TextBox ID="tbMessage" runat="server" Height="117px" TextMode="MultiLine" 
                    Width="400px" CausesValidation="True"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style3">
                Captcha:</td>
            <td>
                <asp:Label ID="lblFirstNum" runat="server" Text=""></asp:Label>
&nbsp;+
                <asp:Label ID="lblSecondNum" runat="server" Text="Label"></asp:Label>
            &nbsp;=
                <asp:TextBox ID="tbResult" runat="server" CausesValidation="True" Width="38px"></asp:TextBox>
&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                    ControlToValidate="tbResult" ErrorMessage="&lt; RequiredField"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style3">
                &nbsp;</td>
            <td>
                <asp:Button ID="btnSend" runat="server" Text="Send" />
&nbsp;<asp:Button ID="btnClear" runat="server" Text="Clear" onclick="btnClear_Click" />
            </td>
        </tr>
    </table>
</asp:Content>

Masterpage

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MainPage.master.cs" Inherits="MainPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <style type="text/css">
        .style1
        {
            width: 900px;
            height: 100%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <table align="center" cellpadding="0" cellspacing="0" class="style1" 
        style="font-family: 'Trebuchet MS'; font-size: small; font-weight: normal; font-style: normal">
        <tr>
            <td bgcolor="#FF6600">

// Important object

                <asp:Panel ID="pnlHeader" runat="server" BackColor="#CC3300" Height="200px">
                    Panel
                </asp:Panel>

//The end of important object

            </td>
        </tr>
        <tr>
            <td bgcolor="#B7B793">
                <asp:ContentPlaceHolder ID="MainData" runat="server">
                </asp:ContentPlaceHolder>
            </td>
        </tr>
         <tr>
            <td>here links</td>
        </tr>
        <tr>
            <td bgcolor="Black" 
                style="font-family: 'Trebuchet MS'; font-size: x-small; font-weight: normal; font-style: normal; color: #Cccccc">
                &nbsp;Copyright &copy; 2010&nbsp;</td>
        </tr>
    </table>
    </form>
</body>
</html>

well. in my masterpage i've added a panel in header. In future i want to put there any nice header image or flash. In the main page i want it to be 200px. high but in my ordinary page i want him to resize (height ~ 100 px.). So I think to do it with timer. But the first problem is that I can't to rich this object from pages. Is there any possibility to reach him, or I have to put panel to every page and this one in masterpage to delete?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.