Solved

LinkButton In Repeater Not Firing with Div on Page

Posted on 2013-06-07
3
764 Views
Last Modified: 2013-06-10
Hi All,

The page has a repeater with linkbuttons in it.  The buttons are not firing up events in the code behind when the lightbox is on the page.  

Outside of the Repeater is a LinkButton "Add New".  This makes the Lightbox show up.  The Lightbox is a <div> with <ajaxToolkit:ModalPopupExtender. (The lightbox Add New Meeting Notes form Works.) Also using javascript tinyMCE in the lightbox- couldn't get the AJAX one to work

When I remove the Lightbox <Div  and the <ajaxToolkit:ModalPopupExtender stays - the repeater linkbuttons work.  It goes to the code behind.  

When I mouse over the Edit link this is what shows up at the bottom:
javascript:WebForm_DoPostBackWithOptions(new WebFrom_PostBackOptions("ct100$contentplacceholder2$Repeater1$ct100$EditBtn", "", true, "", "", false,true))

 Here's the relavent code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Front page:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <tr valign="top">
<td style="width: 149px" class="textBold" >Month: </td>
<td style="width: 412px">
<asp:DropDownList ID="MonthDD" runat="server" AutoPostBack="True">
<asp:ListItem Text="January" Value="1" ></asp:ListItem>
<asp:ListItem Text="February" Value="2"></asp:ListItem>
</asp:DropDownList>
</td>
<td style="text-align: right">
<asp:LinkButton ID="AddBtn" runat="server" class="textBold"  CausesValidation="false">Add New</asp:LinkButton>
</td>
<td style="width: 10px;"></td>
</tr>
<table cellpadding="3" cellspacing="0" style="border-style: inset; border-width: 1px; width: 730px">
<tr>
<td style="height:5px;" colspan="8"></td>
</tr>

<asp:Repeater ID="Repeater1" runat="server" >
<ItemTemplate>      
<%i = i +1 %>                          
<tr bgcolor = <%=(getRowColor(i)) %>>
<td style="width: 10px">&nbsp;</td>
<td style="width: 400px;"><%#Eval("thisMonth") %> <%#Eval("thisDay")%> / <%#Eval("id")%> </td>
<td style="text-align: right"><asp:LinkButton ID="EditBtn" runat="server" CommandName="Edit" CommandArgument='<%#Eval("id")%>' OnCommand="Repeater1_ItemCommand"   Text="Edit"></asp:LinkButton>
</td>
<td style="text-align: right" style="width: 40px">&nbsp;</td>
<td style="text-align: right" style="width: 40px">
<asp:LinkButton ID="PreviewBtn" runat="server" CommandName="Preview" CommandArgument='<%#Eval("id")%>' OnCommand="Repeater1_ItemCommand"  Text="Preview"></asp:LinkButton>
</td>
<td style="width: 40px">&nbsp;</td>
<td style="text-align: right" style="width: 40px">
<asp:LinkButton ID="DeleteBtn" runat="server" CommandName="Delete" CommandArgument='<%#Eval("id")%>'  OnCommand="Repeater1_ItemCommand"  Text="Delete"></asp:LinkButton>
</td>
<td style="width: 10px">&nbsp;</td>
</tr>
</ItemTemplate>
</asp:Repeater>

<tr>
<td style="height:5px;" colspan="8"></td>
</tr>
</table>
<%--~~~~~~~~~~~~        Add New Meeting Info  Area  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--%>
<div id="divPopUP" align="center" style="display:none;width:860px;height:750px;border:solid1px#dddddd; top: 780px;  position: relative; ">
<table cellpadding="0" cellspacing="0" style="width: 843 px;" border="0">
<tr>
<td>
&nbsp;</td>
<td class="textBold" style="width: 174px" align="left">Meeting Date<font color="#990000">*</font>:</td>
<td class="style1" align="left"><asp:TextBox ID="AddMeetingDatetxt" runat="server" style="margin-bottom: 0px" Width="78px"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="AddMeetingDatetxt" PopupButtonID="CalendarBtn" >
</ajaxToolkit:CalendarExtender>
</td>

<td style="width: 524px;" align="left"><asp:ImageButton ID="CalendarBtn" runat="server"  ImageUrl="~/Tools/Images/Calendar2.gif" CausesValidation="false"/> <asp:RequiredFieldValidator ID="AddDateVld" runat="server" ErrorMessage="Please add a date" ControlToValidate="AddMeetingDatetxt" Display="Dynamic" CssClass="textBold" SetFocusOnError="True"></asp:RequiredFieldValidator></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td  class="textBold" align="left">Meeting Notes Text<font color="#990000">*</font>:</td>
<td colspan="2" valign="top">
<asp:RequiredFieldValidator ID="addMeetingTextVLD" runat="server" ErrorMessage="Please add meeting information" ControlToValidate="elm1" CssClass="textBold" Display="Dynamic" SetFocusOnError="True"></asp:RequiredFieldValidator>
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td> &nbsp;</td>
<td colspan="3" align="left">
<asp:TextBox ID="elm1" runat="server" TextMode="MultiLine" ClientIDMode="Static"  Width="766px" Height="500px" /></td>
<td> &nbsp;</td>
<tr>
<td>&nbsp;</td>
<td colspan="3" align="right">
<asp:Button ID="Button1" runat="server" Text="Preview" CausesValidation="False" />&nbsp;&nbsp;&nbsp;
<asp:Button ID="btnHide" runat="server" Text="Cancel" OnClick="btnHide_Click" CausesValidation="False" />&nbsp;&nbsp;&nbsp;
<asp:Button ID="SubmitAddBtn" runat="server" Text="Submit" />
</td>
<td>&nbsp;</td>
</tr>
<%--~~~~~~~~~~~~     END   Add New Meeting Info  Area  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--%>
                       <ajaxToolkit:ModalPopupExtender ID="mpe1" runat="server" TargetControlID="AddBtn" PopupControlID="divPopUP" BackgroundCssClass="modalBackgroundClass" DropShadow="false">
</ajaxToolkit:ModalPopupExtender>      

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here's Code Behind:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  If Not (Page.IsPostBack) Then
            getNotesList()
            i = 1
  End If
End Sub

Protected Sub btnHide_Click(sender As Object, e As System.EventArgs) Handles btnHide.Click
    mpe1.Hide()
End Sub

'~~~~    Adding New Record
Protected Sub SubmitAddBtn_Click(sender As Object, e As System.EventArgs) Handles SubmitAddBtn.Click

    Dim mDate As Date = DateTime.Parse(AddMeetingDatetxt.Text, New System.Globalization.CultureInfo("en-US"))
    Dim mText As String = HttpUtility.HtmlEncode(elm1.Text)
    Dim updater As String = Request.Cookies("LastName").Value
    Dim con As SqlConnection = ExecNonQuerySQL.addData

    Dim strSQL As String = "INSERT INTO DeptMeetingNotes (meetingDate, meetingNotes, updatedDate, updatedBy ) VALUES "
    strSQL = strSQL + "( @sDate, @sText, getDate() , @sUpdater )"

    Dim cmd As New SqlCommand(strSQL, con)

    cmd.Parameters.AddWithValue("@sDate", mDate)
    cmd.Parameters.AddWithValue("@sText", mText)
    cmd.Parameters.AddWithValue("@sUpdater", updater)

    con.Open()
    Dim result As Integer = cmd.ExecuteNonQuery()
    lbl1.Text = result

    AddMeetingDatetxt.Text = ""
    elm1.Text = ""
    mpe1.Hide()

End Sub

'~~~~~~~~~~  Getting List of Notes for Month
Public Sub getNotesList()

    errorLBL.Text = ""
    Repeater1.DataSource = Nothing
    Repeater1.DataBind()

    Dim thisDate As Integer
    Dim strSQL As String
    Dim dr As SqlDataReader

    thisDate = MonthDD.SelectedValue

    strSQL = "SELECT id, Day(meetingDate) as thisDay, DateName(Month,meetingDate) as thisMonth FROM HeadMeetingNotes WHERE Month(meetingDate) = '" & thisDate & "'"
    dr = DataReaderClassIntranetSQL.GetDataReaderIntranetSQL(strSQL)
    If (dr.HasRows) Then
        Repeater1.DataSource = dr
        Repeater1.DataBind()
    Else
        errorLBL.Text = "<font color=red><b>There are no records found for this month.</b></font>"
    End If

End Sub

'~~~~~~~~~    LinkButtons for Edit / Preview / Delete
Protected Sub Repeater1_ItemCommand(sender As Object, e As CommandEventArgs)
    lbl10.Text = ""
    Dim s As String = e.CommandName
    lbl10.Text = s
    Dim t As String = e.CommandArgument
    lbl10.Text = t

    If (e.CommandName.Equals("Delete")) Then
    End If

    If (e.CommandName.Equals("Edit")) Then
        'lbl10.Text = "XXXXXXXXXXXXXXXXXX"
        mpe1.Show()
    End If

    If (e.CommandName.Equals("Preview")) Then
    End If

End Sub

Protected Function getRowColor(thisI As Integer) As String
    If (thisI Mod 2 > 0) Then
        Return "#E7EFF7"
    Else
        Return "#FFFFFF"
    End If

End Function

'~~~~~~~~~~   When User Selects Different Month to View Meeting Notes Records
Protected Sub MonthDD_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles MonthDD.SelectedIndexChanged
    getNotesList()
End Sub


Any Ideas?

JS
0
Comment
Question by:jshesek
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
AnuTiji earned 500 total points
ID: 39234376
Hi

For the linkbuttons inside the repeater set CausesValidation="false" and then give a try
0
 
LVL 1

Author Comment

by:jshesek
ID: 39234773
WOW that worked.  Thank you very much.
0
 
LVL 1

Author Closing Comment

by:jshesek
ID: 39234776
Worked 100%
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question