By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,262 Members | 2,664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,262 IT Pros & Developers. It's quick & easy.

BUG! needs to click button twice to show the summary info!

P: n/a
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">&nbsp;ID&nbsp;(min 4 char):</td>
<td width="78%">&nbsp;
<asp:textbox id="txtID" runat="server" Width="250px"></asp:textbox>
&nbsp;
<asp:label id="lblID" runat="server">(ex.A5570A)</asp:label>&nbsp;
<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>&nbsp;</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?


Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jos
Wang wrote:
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">&nbsp;ID&nbsp;(min 4 char):</td>
<td width="78%">&nbsp;
<asp:textbox id="txtID" runat="server" Width="250px"></asp:textbox>
&nbsp;
<asp:label id="lblID" runat="server">(ex.A5570A)</asp:label>&nbsp;
<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>&nbsp;</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.

--

Jos
Nov 18 '05 #2

P: n/a
Hi

Would you pls try it on your side?
The second round will run success withoud a postback!
How to explain why the page functions well after I change the label's text?

--

Hobbes
"Jos" <jn*************@fastmail.fm> wrote in message
news:ud**************@TK2MSFTNGP15.phx.gbl...
Wang wrote:
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">&nbsp;ID&nbsp;(min 4 char):</td>
<td width="78%">&nbsp;
<asp:textbox id="txtID" runat="server" Width="250px"></asp:textbox>
&nbsp;
<asp:label id="lblID" runat="server">(ex.A5570A)</asp:label>&nbsp;
<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>&nbsp;</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.

--

Jos

Nov 18 '05 #3

P: n/a
I've seen this behavior before (many times). The button is below a validator
that has Display=Dynamic. So that validator is entirely hidden.

When it appears, the button moves down.

Now when you edit the textbox with some illegal data and click on the
button, the first thing that happens is the validator fires due to the
"onchange" event (the button has not yet run). The validator appears. The
button that you are clicking on has just moved. Due to this shift, your
click is ignored.

Solution: Make sure the button does not jump in situations like this by
redesigning your page. Perhaps you should just use Display=Static on the
validator.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Wang" <ho****@sccd.cnuninet.net> wrote in message
news:ul****************@tk2msftngp13.phx.gbl...
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">&nbsp;ID&nbsp;(min 4 char):</td>
<td width="78%">&nbsp;
<asp:textbox id="txtID" runat="server" Width="250px"></asp:textbox>
&nbsp;
<asp:label id="lblID" runat="server">(ex.A5570A)</asp:label>&nbsp;
<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>&nbsp;</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?

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.