Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

eventvalidation razzle dazzle

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Doker - 04 Jul 2007 20:10 GMT
Hello.

I've go a little userwebcontrol that has a button. Tis button when clicked
hides a label and shows a textbox in its place ([code 1]).

Works fine until i put it in a datalist or similiar thing. As you could
expect, or may be you shouldn't, Asp shouts something about event validation.
We all know what it is but the question is how should this object or/and this
event be registred to work correctly.

I know what to do when there is an extra position in combox or similary
(---code--         Page.ClientScript.RegisterForEventValidation(
              this.UniqueID,
              "4"
           );
---/end code ---)
but what with that event.

I even tried [code 2] in the control.
What can i do?

---code 1
<asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline">
   <ContentTemplate>
       <asp:Literal ID="LiteralTresci" runat="server" Mode="PassThrough"
EnableViewState="False"
           Text="[Lokalizowany
       Literal]"></asp:Literal><asp:ImageButton ID="EditButton"
runat="server" SkinID="PrzyciskEdycji"
           OnClick="EditButton_Click" EnableViewState="false"
Visible="False" CausesValidation="False" />
       <table runat="server" id="KontenerEdycji" visible="false"
style="border-collapse: collapse;
           margin: 0; padding: 0; background-color: #ffff99; color: Black;
font-size: 10px;">
           <tr>
               <td style="height: 26px">
                       <asp:TextBox ID="EditTextBox" runat="server"
EnableViewState="False"></asp:TextBox>
                       <asp:LinkButton ID="AcceptBtn" runat="server"
OnClick="AcceptBtn_Click" CausesValidation="False">Apply</asp:LinkButton>
                       <asp:LinkButton ID="CancelBtn" runat="server"
OnClick="CancelBtn_Click" CausesValidation="False">Cancel</asp:LinkButton>
                   
               </td>
           </tr>
       </table>
   </ContentTemplate>
</asp:UpdatePanel>
---/end code 1

---code 2

   void Register(Control ct)
   {
       foreach (Control c in ct.Controls)
       {
           
this.Page.ClientScript.RegisterForEventValidation(c.UniqueID.ToString());
           Register(c);
       }

   }

   protected override void Render(HtmlTextWriter writer)
   {
       Register(this);
       base.Render(writer);
   }

---/end code 2
Doker - 04 Jul 2007 20:54 GMT
I figured out that the problem occures only when DataBind() is called.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.