Current location: Hot Scripts Forums » Programming Languages » ASP.NET » Trouble Repeating Image Buttons


Trouble Repeating Image Buttons

Reply
  #1 (permalink)  
Old 09-07-07, 12:17 PM
spyke01 spyke01 is offline
Newbie Coder
 
Join Date: Aug 2005
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Trouble Repeating Image Buttons

I have the following repeater setup, i have some regular image links that i want to convert to image buttons:
asp Code:
  1. <asp:Repeater ID="rptClientMatterCodes" runat="server">
  2.           <HeaderTemplate>
  3.                <table class="forumborder" border="0" cellpadding="0" cellspacing="1" style="width: 100%;">
  4.                 <tr class="title1">
  5.                     <td colspan="3">
  6.                         Current Client Matter Codes
  7.                     </td>
  8.                 </tr>
  9.                 <tr class="title2">
  10.                     <td>Email Address</td>
  11.                     <td>Long Distance Code</td>
  12.                     <td>&nbsp</td>
  13.                 </tr>
  14.           </HeaderTemplate>
  15.          
  16.           <ItemTemplate>
  17.                <tr class="row2">
  18.                     <td><%#Container.DataItem("email")%></td>
  19.                     <td><%#functions.Padd(Container.DataItem("code"), 4, "0", "L")%></td>
  20.                     <td class="center"><a href="index.asp?action=editCode&id=<%#Container.DataItem("id")%>"><img src="theme/buttons/edit.jpg" alt="Edit Client Matter Code" /></a> &nbsp<a href="index.asp?action=deleteCode&id=<%#Container.DataItem("id")%>" onclick="return confirmDelete('Client Matter Code')"><img src="theme/buttons/delete.jpg" alt="Delete Client Matter Code" /></a></td>
  21.                </tr>
  22.           </ItemTemplate>
  23.          
  24.           <FooterTemplate>
  25.                </table>
  26.           </FooterTemplate>
  27.      </asp:Repeater>

I want the image buttons to take care of editing and deleting, the one im having issues with right now is the deleting one, i want each button to run a function and pass the value of a database field called "id" to the function which will run a delte query on the database based on the id. Heres what i trid to do:

asp Code:
  1. <asp:Repeater ID="rptClientMatterCodes" runat="server">
  2.           <HeaderTemplate>
  3.                <table class="forumborder" border="0" cellpadding="0" cellspacing="1" style="width: 100%;">
  4.                 <tr class="title1">
  5.                     <td colspan="3">
  6.                         Current Client Matter Codes
  7.                     </td>
  8.                 </tr>
  9.                 <tr class="title2">
  10.                     <td>Email Address</td>
  11.                     <td>Long Distance Code</td>
  12.                     <td>&nbsp</td>
  13.                 </tr>
  14.           </HeaderTemplate>
  15.          
  16.           <ItemTemplate>
  17.                <tr class="row1">
  18.                     <td><%#Container.DataItem("email")%></td>
  19.                     <td><%#functions.Padd(Container.DataItem("code"), 4, "0", "L")%></td>
  20.                     <td class="center">
  21.                          <a href="index.asp?action=editCode&id=<%#Container.DataItem("id")%>"><img src="theme/buttons/edit.jpg" alt="Edit Client Matter Code" /></a>
  22.                          &nbsp;
  23.                          <asp:ImageButton ID="btnDelete<%#Container.DataItem("id")%>" runat="server" CommandArgument="<%#Container.DataItem("id")%>" CommandName="btnClickDelete" ImageUrl="theme/buttons/delete.jpg" onclick="return confirmDelete('Client Matter Code')" />
  24.                     </td>
  25.                </tr>
  26.           </ItemTemplate>         
  27.           <FooterTemplate>
  28.                </table>
  29.           </FooterTemplate>
  30.      </asp:Repeater>

The only problem is that it appears that i cant use onclick="return confirmDelete('Client Matter Code')" in asp items, can someone suggest a fix?
Reply With Quote
  #2 (permalink)  
Old 09-07-07, 01:15 PM
spyke01 spyke01 is offline
Newbie Coder
 
Join Date: Aug 2005
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
ok i found out why that way breaking, instead of "" around the eval of the button i need to use '', now im having a different error though, the function im using to make sure that the button is passing the right id is this:

asp Code:
  1. Protected Sub btnSearch_Click(ByVal id As String)
  2.         lblNewUserEmailAddressResult.Text = id
  3.     End Sub

Heres the full page code
asp Code:
  1. <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %>
  2. <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  3.      <asp:Label ID="Label1" runat="server" Text="Generate New Long Distance Code for:"></asp:Label>
  4.      <asp:TextBox ID="txtNewUserEmailAddress" runat="server"></asp:TextBox>&nbsp;<asp:Button ID="btnGenerateCode" runat="server" CssClass="button" Text="Submit" /><br />
  5.      &nbsp;<br />
  6.      <asp:Label ID="lblNewUserEmailAddressResult" runat="server"></asp:Label><br />
  7.      &nbsp;<br />
  8.      
  9.     <asp:TextBox ID="txtSearchEmail" runat="server"></asp:TextBox>
  10.     <asp:Button ID="btnSearch" runat="server" CssClass="button" Text="Search" />
  11.     <br />
  12.      <asp:Repeater ID="rptClientMatterCodes" runat="server">
  13.           <HeaderTemplate>
  14.                <table class="forumborder" border="0" cellpadding="0" cellspacing="1" style="width: 100%;">
  15.                 <tr class="title1">
  16.                     <td colspan="3">
  17.                         Current Client Matter Codes
  18.                     </td>
  19.                 </tr>
  20.                 <tr class="title2">
  21.                     <td>Email Address</td>
  22.                     <td>Long Distance Code</td>
  23.                     <td>&nbsp</td>
  24.                 </tr>
  25.           </HeaderTemplate>
  26.          
  27.           <ItemTemplate>
  28.                <tr class="row1">
  29.                     <td><%#Container.DataItem("email")%></td>
  30.                     <td><%#functions.Padd(Container.DataItem("code"), 4, "0", "L")%></td>
  31.                     <td class="center">
  32.                          <a href="index.asp?action=editCode&id=<%#Container.DataItem("id")%>"><img src="theme/buttons/edit.jpg" alt="Edit Client Matter Code" /></a>
  33.                          &nbsp;
  34.                          <asp:ImageButton runat="server" ID="btnDelete" CommandArgument='<%#Eval("id")%>' CommandName="btnClickDelete" CausesValidation="false" ImageUrl="theme/buttons/delete.jpg" />
  35.                     </td>
  36.                </tr>
  37.           </ItemTemplate>
  38.          
  39.           <AlternatingItemTemplate>
  40.                <tr class="row2">
  41.                     <td><%#Container.DataItem("email")%></td>
  42.                     <td><%#functions.Padd(Container.DataItem("code"), 4, "0", "L")%></td>
  43.                     <td class="center">
  44.                          <a href="index.asp?action=editCode&id=<%#Container.DataItem("id")%>"><img src="theme/buttons/edit.jpg" alt="Edit Client Matter Code" /></a>
  45.                          &nbsp;
  46.                          <asp:ImageButton runat="server" ID="btnDelete" CommandArgument='<%#Eval("id")%>' CommandName="btnClickDelete" CausesValidation="false" ImageUrl="theme/buttons/delete.jpg" />
  47.                     </td>
  48.                </tr>
  49.           </AlternatingItemTemplate>
  50.          
  51.           <FooterTemplate>
  52.                </table>
  53.           </FooterTemplate>
  54.      </asp:Repeater> 
  55.      
  56. </asp:Content>

The error i get is:
Quote:
Server Error in '/LoginExample' Application.
--------------------------------------------------------------------------------

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.]
System.Web.UI.ClientScriptManager.ValidateEvent(St ring uniqueId, String argument) +2127900
System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +106
System.Web.UI.WebControls.ImageButton.RaisePostBac kEvent(String eventArgument) +32
System.Web.UI.WebControls.ImageButton.System.Web.U I.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832
Reply With Quote
  #3 (permalink)  
Old 09-07-07, 01:37 PM
spyke01 spyke01 is offline
Newbie Coder
 
Join Date: Aug 2005
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
found the solutions, i needed to check for post back in page_load and also indtead of the function i was using i needed to use this:

asp Code:
  1. Protected Sub rptClientMatterCodes_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptClientMatterCodes.ItemCommand
  2.         If e.CommandName = "btnClickDelete" Then
  3.             lblNewUserEmailAddressResult.Text = "woot: " & e.CommandArgument
  4.         End If
  5.     End Sub
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Rotation Help aliciany JavaScript 9 12-07-06 07:55 AM
trouble with 'image of the day' code mrblue JavaScript 4 10-06-05 10:15 AM
searching image nurqeen PHP 4 07-09-05 09:35 AM
Help with image on form... Adrianaa03 JavaScript 1 10-06-04 07:38 AM
how to draw an image inside a table? davidklonski HTML/XHTML/XML 2 07-06-04 10:27 AM


All times are GMT -5. The time now is 02:35 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.