J
John Talli
REFERENCE: Masterpage Master Page Conentpage Content Page ContentPlaceHolder Validation
Control
I have a Masterpage\Contentpage with no errors shown in VS2008 but the VALIDATION
control in the Contentpage doesn't fire. I have put the Contentpage in a "regular" aspx
page (no Masterpage) and the VALIDATION control works. It just never fires in the
Masterpage\Contentpage scenerio.
If I leave the textbox empty the validation control should fire. Why doesn't it.
Thanks
MASTER PAGE
===========
<%@ Master Language="VB" CodeFile="Site.master.vb" Inherits="Site"
AutoEventWireup="True" %>
<!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>gmbBlog</title>
<style type="text/css">
.style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="frmMain" runat="server">
<table class="style1">
<tr>
<td>Admin Create New Site</td>
<td>
<asp:HyperLink ID="HyperLink1" runat="server" Text="Admin Create New Site"
NavigateUrl="Admin/Default.aspx" />
</td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="2">
<div id="dvcph_MainContent">
<asp:ContentPlaceHolder id="cph_MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
CONTENT PAGE - ASPX
===================
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="Admin_Default" %>
<asp:Content ID="Content2" ContentPlaceHolderID="cph_MainContent" runat="Server">
<table class="style1">
<tr>
<td>
<div id="dvfrmNameBasis">
<%--Global Hidden Fields--%>
<asp:HiddenField ID="hdn_Is_FirstTimeThru" runat="server" Value="1" />
<asp:HiddenField ID="hdn_UsrID" runat="server" Value="0" />
<div id="dv_aspNet_HTML_Basic">
<asp:ValidationSummary ID="valSum" runat="server" HeaderText="You must enter a valid
value in the following fields:"
DisplayMode="SingleParagraph" Font-Names="verdana" Font-Size="12" />
<table class="style1">
<tr>
<td>
<%--Prs_Who_First_Name--%>
<asp:Label ID="lbl_p_char_Prs_Who_First_Name" runat="server"
CssClass="lbl_Basic_Field_LeftSide" Text="First Name"/>
</td>
<td>
<asp:TextBox ID="txt_p_char_Prs_Who_First_Name" runat="server"
CssClass="txtBx_Basic"
AutoPostBack="True" CausesValidation="True" Enabled="True"
EnableViewState="True"
MaxLength="30" ReadOnly="False" Rows="1" TextMode="SingleLine"
ToolTip=".p_char_Prs_Who_First_Name"
Visible="True" Wrap="True" TabIndex="1" Text="">
</asp:TextBox>
<asp:RequiredFieldValidator ID="emailReqVal"
ControlToValidate="txt_p_char_Prs_Who_First_Name" ErrorMessage="Email. "
Display="Dynamic" Font-Names="Verdana" Font-Size="12" runat="server"
ValidationGroup="valSum" >
*
</asp:RequiredFieldValidator>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="4" align="center">
<asp:Button ID="cmdSave" runat="server" Text="Save" ValidationGroup="valSum"
/>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</asp:Content>
CONTENT PAGE - ASPX.vb
======================
Partial Class Admin_Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub cmdSave_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles cmdSave.Click
Dim b1 As Integer = 0 ' <<<<<<< Gets here before ever VALIDATING the control.
End Sub
End Class
Control
I have a Masterpage\Contentpage with no errors shown in VS2008 but the VALIDATION
control in the Contentpage doesn't fire. I have put the Contentpage in a "regular" aspx
page (no Masterpage) and the VALIDATION control works. It just never fires in the
Masterpage\Contentpage scenerio.
If I leave the textbox empty the validation control should fire. Why doesn't it.
Thanks
MASTER PAGE
===========
<%@ Master Language="VB" CodeFile="Site.master.vb" Inherits="Site"
AutoEventWireup="True" %>
<!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>gmbBlog</title>
<style type="text/css">
.style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="frmMain" runat="server">
<table class="style1">
<tr>
<td>Admin Create New Site</td>
<td>
<asp:HyperLink ID="HyperLink1" runat="server" Text="Admin Create New Site"
NavigateUrl="Admin/Default.aspx" />
</td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
<tr>
<td colspan="2">
<div id="dvcph_MainContent">
<asp:ContentPlaceHolder id="cph_MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
CONTENT PAGE - ASPX
===================
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="Admin_Default" %>
<asp:Content ID="Content2" ContentPlaceHolderID="cph_MainContent" runat="Server">
<table class="style1">
<tr>
<td>
<div id="dvfrmNameBasis">
<%--Global Hidden Fields--%>
<asp:HiddenField ID="hdn_Is_FirstTimeThru" runat="server" Value="1" />
<asp:HiddenField ID="hdn_UsrID" runat="server" Value="0" />
<div id="dv_aspNet_HTML_Basic">
<asp:ValidationSummary ID="valSum" runat="server" HeaderText="You must enter a valid
value in the following fields:"
DisplayMode="SingleParagraph" Font-Names="verdana" Font-Size="12" />
<table class="style1">
<tr>
<td>
<%--Prs_Who_First_Name--%>
<asp:Label ID="lbl_p_char_Prs_Who_First_Name" runat="server"
CssClass="lbl_Basic_Field_LeftSide" Text="First Name"/>
</td>
<td>
<asp:TextBox ID="txt_p_char_Prs_Who_First_Name" runat="server"
CssClass="txtBx_Basic"
AutoPostBack="True" CausesValidation="True" Enabled="True"
EnableViewState="True"
MaxLength="30" ReadOnly="False" Rows="1" TextMode="SingleLine"
ToolTip=".p_char_Prs_Who_First_Name"
Visible="True" Wrap="True" TabIndex="1" Text="">
</asp:TextBox>
<asp:RequiredFieldValidator ID="emailReqVal"
ControlToValidate="txt_p_char_Prs_Who_First_Name" ErrorMessage="Email. "
Display="Dynamic" Font-Names="Verdana" Font-Size="12" runat="server"
ValidationGroup="valSum" >
*
</asp:RequiredFieldValidator>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="4" align="center">
<asp:Button ID="cmdSave" runat="server" Text="Save" ValidationGroup="valSum"
/>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</asp:Content>
CONTENT PAGE - ASPX.vb
======================
Partial Class Admin_Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub cmdSave_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles cmdSave.Click
Dim b1 As Integer = 0 ' <<<<<<< Gets here before ever VALIDATING the control.
End Sub
End Class