AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
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
Hi!
I am using c# at backend.
problem:
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:ScriptManager>

<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>
</asp:Panel>

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


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

<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();
Panel1_ModalPopupExtender.Show();
}

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

 
Sponsored by
The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks - Free 158 Page Preview
Speech Technology Magazine
No Nonsense XML Web Development With PHP - Free 146 Page Preview!