J
Jos
Wang said:Here is the code for a webcontrol, quite simple:
-------------------------------------------------------------------------- -----------------------------------
<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="WebUserControl1.ascx.cs"
Inherits="WebApplication23.WebUserControl1"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<STYLE>
.ModuleContent P { FONT-SIZE: x-small; FONT-FAMILY: Arial, Verdana,
Helvetica }
LI { FONT-SIZE: x-small; FONT-FAMILY: Arial, Verdana, Helvetica }
A { FONT-SIZE: x-small; FONT-FAMILY: Arial, Verdana, Helvetica }
TD { FONT-SIZE: x-small; FONT-FAMILY: Arial, Verdana, Helvetica }
TH { FONT-SIZE: x-small; FONT-FAMILY: Arial, Verdana, Helvetica }
DIV { FONT-SIZE: x-small; FONT-FAMILY: Arial, Verdana, Helvetica }
</STYLE>
<table cellSpacing="0" cellPadding="0" width="490" border="0">
<tr>
<td width="5%"></td>
<td width="95%"><asp:label id="lblMessage" runat="server"
EnableViewState="False" ForeColor="Red"
Font-Bold="True"></asp:label><asp:validationsummary id="ValSummary"
runat="server" Font-Bold="True"
DisplayMode="SingleParagraph"></asp:validationsummary><br>
<table cellSpacing="0" cellPadding="5" border="0" width="100%">
<tr bgColor="#ebebeb">
<td colSpan="2"></td>
</tr>
<tr bgColor="#ebebeb">
<td style="WIDTH: 105px" width="105"> ID (min 4 char):</td>
<td width="78%">
<asp:textbox id="txtID" runat="server" Width="250px"></asp:textbox>
<asp:label id="lblID" runat="server">(ex.A5570A)</asp:label>
<asp:regularexpressionvalidator id="RegExpValId" runat="server"
Font-Bold="True" ValidationExpression=".{4,}"
ControlToValidate="txtID"
Display="Dynamic" Font-Size="Medium" ErrorMessage="This is the error
message!">*</asp:regularexpressionvalidator></td>
</tr>
<tr bgColor="#ebebeb">
<td colSpan="2"><asp:button id="btnSearch" runat="server"
Text="Search"></asp:button> </td>
</tr>
</table>
</td>
</tr>
</table>
-------------------------------------------------------------------------- --------------------------------
A rather simple form, The webcontrol contains a textbox and a
validation
control.
the button needs to click twice to show the summary error message!
The question can be resolved by one of the following operations:
1,change the textbox's width or remove the css
2,I remove the left side table cell
3,change the label lblID's text to either "(ex.A5570AA)" or
"(ex.A5570)".
But I want to know why?
I'm guessing that the problem is in your page, not in your control.
How is the control generated on the page?
If it is generated dynamically, make sure it gets the same ID
before and after postback.
Otherwise, your button will also get a different ID after
postback, causing event handling to fail.
The first and the second postback on the other hand will
generate the same ID's, allowing a successful event handling.