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? 3 2493
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"> 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.
--
Jos
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"> 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.
--
Jos
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"> 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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Baoqiu Cui |
last post by:
Today I was playing with a small Python program using Python 2.4
on Cygwin (up-to-date version, on Windows XP), but ran into a
strange error on the following small program (named bug.py):
...
|
by: Antonio Maiorano |
last post by:
Hi everyone,
I use Visual Studio .NET 2002 right now, and I discovered a bug last night
that I have found few references to on the internet. Basically, if you
allocated a null-terminated char...
|
by: Drew D. Saur |
last post by:
Hello, all.
I have searched and searched and searched for details about what I am
experiencing, but I can't find a reference anywhere. I know IE has some
interesting bugs regarding floats - many...
|
by: Jerry |
last post by:
I managed to narrow this down to a very simple expression. try this:
private void Bug()
{
bool b = false;
Test(3, (b || b) && b && !b);
}
private void Works()
{
|
by: Maxim Yegorushkin |
last post by:
The following code:
#include <iostream>
class base
{
private:
virtual ~base()
{
std::cout << "virtual ~base()\n";
|
by: Xah Lee |
last post by:
i had the pleasure to read the PHP's manual today.
http://www.php.net/manual/en/
although Pretty Home Page is another criminal hack of the unix lineage,
but if we are here to judge the quality...
|
by: GaryDean |
last post by:
A couple of weeks ago I reported a bug in vs2005 where it corrupted projects
converted from vs2003 if a 2003 dataset were modified or recreated. Steven
Cheng was able to recreate the bug. I ...
|
by: Edward Diener |
last post by:
After spending more than a day reducing a complicated compiler bug to a
simple case I reported it to the MSDN Product Feedback Center as a bug
just now. However this bug is completely stymying my...
|
by: Patient Guy |
last post by:
The code below shows the familiar way of restricting a function to be a
method of a constructed object:
function aConstructor(arg)
{
if (typeof(arg) == "undefined")
return (null);...
|
by: Juan T. Llibre |
last post by:
re:
!I found an MSDN document that explains why what I'm trying to do should work
Lee,
From :
http://www.w3.org/TR/REC-xml/
"A special attribute named xml:lang may be inserted in...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |