Asp.Net News
Free Tech Magazines
Asp.Net Web Hosting
Suggest Us
Link to Us
Feeds Subscription
Questions & Answers
Tips & Tricks
 how to show popup from repeater controll event from backend
Posted by syed afroz on  6/18/2010 7:01:57 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
I am using c# at backend.
i have a link button in repeater binded with some value ,when i click on that link button it should perform some task in backend and at same time popup should appear indicating suitable message..

Plz help me..

Post Your Reply Post New Question

 Viewer's Reply
Sample Code to Open ModalPopup Extender From Asp.Net Repeater Control
Answered By Moderator1 on 6/20/2010 9:07:45 PM
I'm giving here a sample code to open Modal Popup in Repeater control through Server-side code. When you click on the Open Popup link, it will write the Date and Time in label control. Same way, it will write the Date and Time when the Popup is closed. Change it to suite your requirement.

In the Aspx Design View, add a Label control, a LinkButton control, a Repeater control and a SQLDataSource control. Bind the Repeater and SQLDataSource.
Also add a Panel and ModalPopupExtender control and set its properties are below,

<asp:ScriptManager ID="ScriptManager1" runat="server">

<asp:Label ID="lblTime" runat="server" Text="I'm going to Write Date and Time here"></asp:Label>

<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" style="display:none;width:350px;padding:10px" >
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="Button2_Click">Close this Window</asp:LinkButton>

<cc1:ModalPopupExtender ID="Panel1_ModalPopupExtender" runat="server"
BackgroundCssClass="modalBackground" RepositionMode="RepositionOnWindowScroll"
TargetControlID="hiddenTargetControlForModalPopup" PopupControlID="Panel1">
<asp:Button runat="server" ID="hiddenTargetControlForModalPopup" style="display:none"/>

<br />
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<table width="100%">
<td width="50%"><asp:Label ID="Label1" runat="server" Text='<%# Bind("DataDesc") %>'></asp:Label></td>
<td width="50%">
<asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">Open Popup</asp:LinkButton>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TestConnectionString %>"
SelectCommand="SELECT * FROM [TestData]"></asp:SqlDataSource>

In the code-behind page, in the LinkButton1's click event and LinkButton2 (inside Repeater control) click event add the below code.

protected void LinkButton1_Click(object sender, EventArgs e)
lblTime.Text = "Modal Popup Opened at " + DateTime.Now.ToString();

protected void LinkButton2_Click(object sender, EventArgs e)
lblTime.Text = "Modal Popup Closed at " + DateTime.Now.ToString();
Post Your Reply If you still have problem, post it again under this reply for better response.

Sponsored by
Many .NET teams are underperforming, is yours?
Introduction to Software Development
When Good HTML Goes Bad: How You Can Protect Your Web Applications