ModalPopupExtender

R

robasta

I need help, I am stuck.

Scenario: I am using a Datalist showing Images. When a user clicks on
an Image, the ModalPopup should show the selected image.

Currently I have the following:

CODE BEHIND:
-----------------------

protected void OKButton_Click(object sender, EventArgs e)
{
//submit entry, add to db, add to show entry
string insertResult = CompetitionEntryManager.AddEntry
(Session["selImg"].ToString(), PageHelper.SessionEmailAddress,
txtboxTextEntry.Text);
if (insertResult == "Success")
{
//redirect to view the post
}
else
{
//show error message
}
}

protected void rep2_SelectedIndexChanged(object sender,
EventArgs e)
{
if (PageHelper.SessionEmailAddress == string.Empty)
{
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
}
else
{
Session["selImg"] = rep2.SelectedValue.ToString();
txtboxTextEntry.Text = rep2.SelectedValue.ToString();
}
}

protected void rep2_ItemCommand(object source,
DataListCommandEventArgs e)
{
Session["selItem"] =
e.Item.ItemIndex;
}
-------------------------------------------------------------------
------------------------------------------------------------------

ASPX:
---------

<asp:DataList ID="rep2" DataSourceID="linqDataSourceImageDisplays"
runat="server"
RepeatDirection="Horizontal" RepeatColumns="4"
BackColor="White" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3"
GridLines="Vertical"
OnSelectedIndexChanged="rep2_SelectedIndexChanged"
DataKeyField="ImageUrl" OnItemCommand="rep2_ItemCommand">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<ItemTemplate>
<table width="100%" border="0" cellspacing="0"
cellpadding="0px" class="competitionImageTable">
<tr>
<td>
<asp:Image ID="ImageButton" runat="server"
ImageUrl='<%# Eval("ImageUrl") %>'
Width="200px" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="ImageTitleLabel" runat="server"
Text='<%# Eval("ImageTitle") %>' />
</td>
</tr>
<tr>
<td>
<asp:Label ID="ImageDescriptionLabel"
runat="server" Text='<%# Eval("ImageDescription") %>' />
</td>
</tr>
<tr>
<td>
<asp:LinkButton runat="server"
CommandName="Select" Text="Select" />
</td>
</tr>
</table>
<act:ModalPopupExtender runat="server"
TargetControlID="ImageButton"
PopupControlID="ModalPanel"
CancelControlID="CancelButton"
BackgroundCssClass="ModelPopupBackground">
</act:ModalPopupExtender>
</ItemTemplate>
<SelectedItemTemplate>
<table width="100%" border="0" cellspacing="0"
cellpadding="0px" class="competitionImageTable">
<tr>
<td>
<asp:Image ID="ImageButton" runat="server"
ImageUrl='<%# Eval("ImageUrl") %>'
Width="200px" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="ImageTitleLabel" runat="server"
Text='<%# Eval("ImageTitle") %>' />
</td>
</tr>
<tr>
<td>
<asp:Label ID="ImageDescriptionLabel"
runat="server" Text='<%# Eval("ImageDescription") %>' />
</td>
</tr>
<%--<tr>
<td>
<asp:LinkButton ID="LinkButton1"
runat="server" CommandName="Select" Text="Select" />
</td>
</tr>--%>
</table>
</SelectedItemTemplate>
<AlternatingItemStyle BackColor="#DCDCDC" />
<ItemStyle BackColor="#EEEEEE" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True"
ForeColor="White" />
</asp:DataList>
<asp:LinqDataSource ID="linqDataSourceImageDisplays"
runat="server"
ContextTypeName="Nescafe.MidTier.NescafeMidTierDataContext"
Select="new (ImageUrl, ImageTitle, ImageDescription)"
TableName="CompetitionImages"
Where="IsActive == @IsActive">
<WhereParameters>
<asp:parameter DefaultValue="true" Name="IsActive"
Type="Boolean" />
</WhereParameters>
</asp:LinqDataSource>
<asp:panel ID="ModalPanel" runat="server" Width="500px">
<table width="500px" border="0" cellspacing="0"
cellpadding="0" class="PopupTable">
<tr>
<td colspan="2">
<asp:Label ID="labelEntryText" runat="server"
Text="Entry Text"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<asp:TextBox ID="txtboxTextEntry" runat="server"
Columns="50" Style="margin-left: 0px"
TextMode="MultiLine"></asp:TextBox>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtboxTextEntry"
ErrorMessage="RegularExpressionValidator"
ValidationExpression="^[a-zA-Z0-9\s.\-]+$">*</
asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<asp:Button ID="CancelButton" runat="server"
Text="Close" />
</td>
<td>
<asp:Button ID="OKButton" runat="server"
Text="Submit" OnClick="OKButton_Click" />
</td>
</tr>
</table>
</asp:panel>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,630
Members
45,335
Latest member
Tommiesal

Latest Threads

Top