We have added a new gallery page to our website, which displays a series of thumbnails using
We would like to display popup window to display the image in a larger format and have used the following code so far -
ScriptManager.RegisterStartupScript(Me, GetType(String), "New_Window", "window.open('" & webUrl & "Cacique4.jpg', null, 'height=400,width=400,status=yes,toolbar=yes,menubar=yes,location=no' );", True)
The window displays like a normal browser only sized to 400x400.
Is there any way to display the image in a pop up window?
Here's an example:
ASPX:
<head runat="server">
<title>Modal Popup</title>
<style type="text/css">
.modalStyle
{
background-color: Gray;
filter: alpha(opacity=70);
opacity: 0.7;
}
.panelStyle
{
width: 300px;
height: 180px;
border: 2px solid Gray;
background-color:White;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="scripManager" runat="server" />
<asp:ModalPopupExtender ID="modal" CancelControlID="btnCancel" BackgroundCssClass="modalStyle" PopupControlID="popup" TargetControlID="lblPopup" runat="server" />
<asp:Label ID="lblPopup" runat="server" />
<asp:Panel runat="server" ID="popup" CssClass="panelStyle">
<table style="width: 100%;">
<tr>
<td>
<asp:RadioButton ID="rdboption1" AutoPostBack="true" OnCheckedChanged="CheckedChanged" runat="server" Text="Option 1" GroupName="Options" /><br />
<asp:RadioButton ID="rdboption11" runat="server" Text="Option 1.1" GroupName="SubOption1"
Visible="false" /><br />
<asp:RadioButton ID="rdboption12" runat="server" Text="Option 1.2" GroupName="SubOption1"
Visible="false" />
</td>
</tr>
<tr>
<td>
<asp:RadioButton ID="rdboption2" AutoPostBack="true" OnCheckedChanged="CheckedChanged" runat="server" Text="Option 2" GroupName="Options" /><br />
<asp:RadioButton ID="rdboption21" runat="server" Text="Option 2.1" GroupName="SubOption2"
Visible="false" /><br />
<asp:RadioButton ID="rdboption22" runat="server" Text="Option 2.2" GroupName="SubOption2"
Visible="false" />
</td>
</tr>
<tr>
<td style="text-align: center;">
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
</form>
</body>
Code behind:
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
modal.Show();
}
protected void CheckedChanged(object sender, EventArgs e)
{
var radioButton = sender as RadioButton;
ResetOptions();
switch(radioButton.ID)
{
case "rdboption1":
rdboption11.Visible = true;
rdboption12.Visible = true;
break;
case "rdboption2":
rdboption21.Visible = true;
rdboption22.Visible = true;
break;
}
}
private void ResetOptions()
{
rdboption11.Visible = false;
rdboption12.Visible = false;
rdboption21.Visible = false;
rdboption22.Visible = false;
}
}
Related
I have a ASPxGridView consist of a image column. When I click the ExportToPDF,images are shown in pdf. But if I click the ExportToXls, images are not shown in the excel. What is the problem ?
I use Devexpress 14.2 in visual studio.
P.S. = Images in gridview are different sizes.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td style="padding-right: 4px">
<dx:ASPxButton ID="btnPdfExport" runat="server" Text="Export to PDF" OnClick="btnPdfExport_Click" />
</td>
<td style="padding-right: 4px">
<dx:ASPxButton ID="btnXlsExport" runat="server" Text="Export to XLS" OnClick="btnXlsExport_Click" />
</td>
<td style="padding-right: 4px">
<dx:ASPxButton ID="btnXlsxExport" runat="server" Text="Export to XLSX" OnClick="btnXlsxExport_Click" />
</td>
<td style="padding-right: 4px">
<dx:ASPxButton ID="btnRtfExport" runat="server" Text="Export to RTF" OnClick="btnRtfExport_Click" />
</td>
<td>
<dx:ASPxButton ID="btnCsvExport" runat="server" Text="Export to CSV" OnClick="btnCsvExport_Click" />
</td>
</tr>
</table>
<dx:ASPxGridView ID="Grid" runat="server" AutoGenerateColumns="False" DataSourceID="XmlDataSource1">
<Columns>
<dx:GridViewDataTextColumn FieldName="Common_Name" Caption="Common name" />
<dx:GridViewDataTextColumn FieldName="Species_Name" Caption="Species name" />
<dx:GridViewDataImageColumn FieldName="ImagePath" Caption="Image">
<PropertiesImage>
<ExportImageSettings Width="180" Height="120" />
</PropertiesImage>
</dx:GridViewDataImageColumn>
</Columns>
<SettingsPager PageSize="30" />
</dx:ASPxGridView>
<dx:ASPxGridViewExporter ID="GridExporter" runat="server" GridViewID="Grid" OnRenderBrick="GridExporter_RenderBrick" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Intranet/denemebru/Fishes.xml" />
</form>
</body>
</html>
public partial class Intranet_denemebru_RaporDeneme2 : System.Web.UI.Page
{
protected void GridExporter_RenderBrick(object sender, ASPxGridViewExportRenderingEventArgs e)
{
var dataColumn = e.Column as GridViewDataColumn;
if (dataColumn != null && dataColumn.FieldName == "ImagePath" && e.RowType == GridViewRowType.Data)
e.ImageValue = GetImageBinaryData(e.Value.ToString());
}
protected void btnPdfExport_Click(object sender, EventArgs e)
{
GridExporter.WritePdfToResponse();
}
protected void btnXlsExport_Click(object sender, EventArgs e)
{
GridExporter.WriteXlsToResponse();
}
protected void btnXlsxExport_Click(object sender, EventArgs e)
{
GridExporter.WriteXlsxToResponse();
}
byte[] GetImageBinaryData(string relativePath)
{
string path = Server.MapPath(relativePath);
return File.Exists(path) ? File.ReadAllBytes(path) : null;
}
}
1My first question ever here, forgive if I am not fluent in tech language because I am a self taught developer from deep Africa Mozambique, thanks to this site.
My question is I have a
public void topicView_ItemDataBound(object sender,e)
In my code behind for a particular aspx page with a repeater, that receives its info from a datatable (if my terminology is correct.) The ItemDataBound event is to arrange my controls in a repeater for the purpose of hiding, disabling and showing other controls according to the determined criterias. Now I have noticed that the ItemDataBound event is slowing my page load time by some 20 to 40 seconds which is really bad, even on post back. When i remove the ItemDataBound events. I am running smoothly. But i can't work with out the ItemDataBound event since its the only way i know how to arrange a repeater with alternating conditions. Is this a common problem with a quick answer or should i post my full code?? this only happens on 2 pages with this event. I am using c# if thats of any help. net.4.5
public void topicView_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
// Show or hid div here
HiddenField MediaType = (HiddenField)e.Item.FindControl("MediaType");
HiddenField PageAdmin = (HiddenField)e.Item.FindControl("PageAdmin");
HiddenField f1 = (HiddenField)e.Item.FindControl("F1");
HiddenField PP = (HiddenField)e.Item.FindControl("PP");
HiddenField isread= (HiddenField)e.Item.FindControl("isread");
HiddenField tread = (HiddenField)e.Item.FindControl("tread");
// Label Label2 = (Label)e.Item.FindControl("Label2");
// Label2.Text = myDDL.Value;
System.Web.UI.HtmlControls.HtmlContainerControl image_video = (System.Web.UI.HtmlControls.HtmlContainerControl)e.Item.FindControl("image_video");
System.Web.UI.HtmlControls.HtmlContainerControl image_pic = (System.Web.UI.HtmlControls.HtmlContainerControl)e.Item.FindControl("image_pic");
System.Web.UI.HtmlControls.HtmlContainerControl PP1 = (System.Web.UI.HtmlControls.HtmlContainerControl)e.Item.FindControl("PP1");
System.Web.UI.HtmlControls.HtmlContainerControl userpic = (System.Web.UI.HtmlControls.HtmlContainerControl)e.Item.FindControl("userpic");
System.Web.UI.HtmlControls.HtmlContainerControl compic = (System.Web.UI.HtmlControls.HtmlContainerControl)e.Item.FindControl("compic");
System.Web.UI.HtmlControls.HtmlContainerControl userpic2 = (System.Web.UI.HtmlControls.HtmlContainerControl)e.Item.FindControl("userpic2");
System.Web.UI.HtmlControls.HtmlContainerControl compic2 = (System.Web.UI.HtmlControls.HtmlContainerControl)e.Item.FindControl("compic2");
System.Web.UI.HtmlControls.HtmlContainerControl pf = (System.Web.UI.HtmlControls.HtmlContainerControl)e.Item.FindControl("pf");
System.Web.UI.HtmlControls.HtmlContainerControl attach = (System.Web.UI.HtmlControls.HtmlContainerControl)e.Item.FindControl("attach");
LinkButton LinkButton3 = (LinkButton)e.Item.FindControl("LinkButton3");
LinkButton LinkButton1 = (LinkButton)e.Item.FindControl("LinkButton1");
Label Label4 = (Label)e.Item.FindControl("Label4");
Label Label10 = (Label)e.Item.FindControl("Label10");
System.Web.UI.WebControls.Image readsign = (System.Web.UI.WebControls.Image)e.Item.FindControl("readsign");
System.Web.UI.WebControls.Image Image2 = (System.Web.UI.WebControls.Image)e.Item.FindControl("Image2");
if (MediaType.Value == "video")
{
image_video.Visible = false;
image_pic.Visible = true;
Image2.ImageUrl = "~/images/readmail.png";
}
if (MediaType.Value == "image")
{
image_video.Visible = true;
image_pic.Visible = false;
}
if (MediaType.Value == "" ) { attach.Visible = false; } else { attach.Visible = true; }
if (PageAdmin.Value == "False")
{
compic.Visible = false;
userpic.Visible = true;
userpic2.Visible = true;
compic2.Visible = false;
}
if (PageAdmin.Value == "True")
{
userpic.Visible = false;
compic.Visible = true;
userpic2.Visible = false;
compic2.Visible = true;
}
if (isread.Value == "True")
{
readsign.ImageUrl = "~/images/readmail.png";
Label4.Text = "foi lido ";
Label10.Text = tread.Value;
}
}
}
and my aspx code for the repeater:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"
OnItemDataBound="topicView_ItemDataBound"><ItemTemplate>
<div id="messages" style="margin-bottom: 10px">
<asp:HiddenField ID="Status" runat="server"
Value='<%#""+Eval("Isreplyed") %>' />
<asp:HiddenField ID="Pageadmin" runat="server"
Value='<%#""+Eval("PageAdmin") %>'/>
<asp:HiddenField ID="MediaType" runat="server"
Value='<%#""+Eval("MediaType") %>' />
<asp:HiddenField ID="isread" runat="server" Value='<%#""+Eval("Isread")
%>' />
<asp:HiddenField ID="tread" runat="server" Value='<%#""+Eval("tread","
{0:d / MM " + "#" + " HH:mm}") %>' />
<div id="Omsg" style="padding: 5px; border: thin solid #FFFFFF; box-
shadow:rgba(255, 255, 255,0.9) 0 0 7px; background-color: #FFFFFF;border-
radius:5px; " >
<table style="width: 100%; text-align: left; margin-left: 0px;">
<tr><td colspan="2">
<asp:Image ID="readsign" runat="server" Height="25" Width="25"
ImageUrl="~/images/newmail.png" />
<asp:Label ID="Label4" runat="server" Text='<%# ""+Eval("Isreplyed")
%>' Font-Size="X-Small" ForeColor="#999999"></asp:Label>
<asp:Label ID="Label10" runat="server" Text='<%#""+Eval("datesent","{0:d /
MM " + "#" + " HH:mm}") %>' Font-Size="X-Small" ForeColor="#999999">
</asp:Label>
</td></tr>
<tr>
<td style="width: 66px; text-align: left;"><a id="pps" ><div
id="compic" ClientIDMode="Static" runat="server"><img id="PP1" alt=""
class="img-rounded" src='<%#"/ProfilePictures/"+Eval("logo") %>'
style="width: 50px; height: 50px" /></div><input id="Hidden2" type="hidden"
runat="server" value='<%#"/ProfilePictures/"+Eval("logo") %>' /></a>
<div id="userpic" clientidmode="Static" runat="server">
<img alt="" class="img-circle"
src='<%#"/ProfilePictures/"+Eval("ProfilePicture") %>' style="width: 50px;
height: 50px" />
</div><input id="Hidden3" type="hidden" runat="server"
value='<%#"/ProfilePictures/"+Eval("ProfilePicture") %>' />
</td>
<td style="line-height: 15px"> <div id="compic2"
ClientIDMode="Static" runat="server"> <a href='<%#"/Landing.aspx?
Restid="+Eval("id") %>' ><asp:Label ID="Label2" class="head" runat="server"
Text='<%# ""+Eval("name") %>' Font-Size="Medium" ForeColor="#B9A47B">
</asp:Label> </a><a/><br/>
<asp:Label ID="CName" runat="server"
Text='<%#""+Eval("slogan") %>' Font-Size="Smaller"></asp:Label>. ...</div>
<div id="userpic2" ClientIDMode="Static"
runat="server"><a href='<%#"/Landing.aspx?Restid="+Eval("Username") %>' >
<asp:Label ID="Label8" class="head" runat="server"
Text='<%#""+Eval("Username") %>' Font-Size="Large" ForeColor="#B9A47B">
</asp:Label> <a/><br/>
<asp:Label ID="Label9" runat="server"
Text='<%#""+Eval("Job") %>' Font-Size="Smaller"></asp:Label></a>
<br />
<a/>
<a href='<%#"notificationmaster.aspx?BlogId="+Eval("Blogid") %>'> <asp:Label
ID="Label5" runat="server" Text='<%# "Respondendo à publicação :
"+Eval("BlogTitle") %>' Font-Size="smaller" ForeColor="#B9A47B"></asp:Label>
</a><br/>
</div>
<a/><span style="font-size: x-small; color: #999999">
enviado : </span><asp:Label ID="Label3" runat="server"
Text='<%#""+Eval("datesent","{0:d MMMM yyyy - HH:mm}") %>' Font-Size="X-
Small" ForeColor="#999999"></asp:Label></a>
<br />
<div id="attach" ClientIDMode="Static" runat="server" >
<asp:Label ID="Label17" runat="server" Text="Esta mensagem tem anexo"
ForeColor="#999999" Font-Size="X-Small" Font-Underline="True">
</asp:Label> <img alt="" src="images/attach.png" style="width: 20px;
height: 20px" /></div>
</td>
</tr>
<tr>
<td colspan="2">
<br/>
<div id="msgbody" style="display: none">
<asp:Label ID="Label1" runat="server" Text='<%#""+Eval("mbody") %>'>
</asp:Label><br/>
<div id="image_pic" ClientIDMode="Static" runat="server" >
<asp:HiddenField ID="HiddenField1" runat="server"
Value='<%#"/PostImages/"+Eval("image") %>' />
<asp:Image ID="Image1" class="img-thumbnail" ClientIDMode="Static"
runat="server" ImageUrl='<%#"/PostImages/"+Eval("image") %>' alt="Broken"
Width="100%" />
</div>
<div id="image_video" runat="server" onclick="AddView" >
<video id="PostVedio" runat="server" controls
poster="/images/chimoioonline.png" src='<%#"/video/"+Eval("video") %>'
style="width: 100%">
<source src="demo.mp4" type="video/mp4" />
<source src="demo.webm" type="video/webm"/>
<source src="demo.ogv" type="video/ogg"/>
<source src="demo.ogv" type="video/avi"/>
<p>Fallback code if video isn't supported</p>/
</video></div></div>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: right">
<hr style="padding: 2px; margin: 5px" />
<div id="deletm" style="display: inline-block">
<input id="Hidden1" type="hidden" runat="server"
value='<%#Eval("id")%>' />
<asp:LinkButton ID="LinkButton3" runat="server" CssClass="btn"
onclick="pmdelet" BorderColor="#CCCCCC" BorderWidth="1px"><img
src="/images/delete.png" alt="" style=" height: 15px" />
</asp:LinkButton> <br />
</div>
<div id="sendpm" style="display: inline-block">
<input id="mido" type="hidden" runat="server"
value='<%#Eval("id")%>' />
<input id="Hidden4" type="hidden" runat="server"
value='<%#Eval("BlogId")%>' />
<input id="sender2" type="hidden" runat="server"
value='<%#Eval("sender")%>' />
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="btn"
BorderColor="#CCCCCC" BorderWidth="1px" OnClientClick=""
PostBackUrl='<%#"PMS.aspx?id=" + Eval("id") + "&BlogId=" + Eval("BlogId")+
"&sender=" + Eval("sender")%>' ><img src="images/pvtemail.png" alt=""
style=" height: 15px" /></asp:LinkButton>
</div>
<div id="read" style="display: inline-block">
<input id="H5" type="hidden" runat="server"
value='<%#Eval("id")%>' />
<input id="H7" type="hidden" runat="server"
value='<%#"/ProfilePictures/"+Eval("logo") %>' />
<input id="H8" type="hidden" runat="server"
value='<%#"/ProfilePictures/"+Eval("ProfilePicture") %>' />
<input id="H6" type="hidden" runat="server"
value='<%#Eval("Isreplyed")%>' />
<input id="H14" type="hidden" runat="server"
value='<%#Eval("Username")%>' />
<input id="H10" type="hidden" runat="server"
value='<%#Eval("name")%>' />
<input id="H13" type="hidden" runat="server"
value='<%#Eval("Subject")%>' />
<input id="H9" type="hidden" runat="server"
value='<%#Eval("BlogTitle")%>' />
<input id="H11" type="hidden" runat="server"
value='<%#Eval("datesent","{0:d / MM " + "#" + " HH:mm}")%>' />
<input id="H12" type="hidden" runat="server"
value='<%#Eval("mbody")%>' />
<input id="v5" type="hidden" runat="server" value='<%#
Eval("video")%>' />
<input id="p5" type="hidden" runat="server"
value='<%#Eval("image")%>' />
<input id="sender" type="hidden" runat="server"
value='<%#Eval("sender")%>' />
<input id="Hidden5" type="hidden" runat="server"
value='<%#Eval("Blogid")%>' />
<input id="PageAdmin2" type="hidden" runat="server"
value='<%#Eval("PageAdmin")%>' />
<asp:LinkButton ID="LinkButton2" runat="server" CssClass="btn"
BorderColor="#CCCCCC" BorderWidth="1px" OnClientClick="return false"><img
src="/images/read2.png" alt="" style=" height:15px" /></asp:LinkButton>
</div>
</td>
</tr>
</table>
</div>
<div id="Rmsg">
</div>
</div>
</ItemTemplate></asp:Repeater>
My Server profiler screen shot
This is not really an answer, but more a way for you to delve deeper into whats the problem. (And it's to long for a comment)
First of all you need to make sure you have SQL server managment tools installed, in particular you need the tool called SQL server profiler.
In profiler you go to "file" "new trace" and connect to you SQL server.
In the Trace properties you select only "RPC:completed" and "SQL:BatchCompleted".
Now you can run your aspx page, and you should se all SQL queries generated by the page in the profiler. There are two things you should look out for.
First of all, look for long running queries. The duration column is in MS and you should not have anyone longer than 1000ms.
Secondly, the number of queries run when the page is run. A normal page should not exceed 20 queries. Usualy when you get problems with this, you could run hundreds.
I have this view in my asp.net application :
<asp:UpdatePanel ID="C_Compte" runat="server" UpdateMode="Conditional">
<ContentTemplate>
Métier:
<asp:TextBox ID="tbAddMetier" CssClass="Textboxes" Width="300px" Height="25px" runat="server"></asp:TextBox>
<asp:Button ID="btnAddMetier" runat="server" Text="Ajouter" CssClass="OffreEmploiSearch" OnClick="Button1_Click" />
<h4 style="font-weight: bold">Mes métiers</h4>
<asp:Repeater ID="rptrMetier" runat="server">
<ItemTemplate>
<div style="font: normal normal normal 14px/1.4em play, sans-serif; color: rgb(95, 94, 93); padding-left: 10px; line-height: 22px">
<strong><%# Eval("Lebelle") %></strong></a>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Design_Ressources/img/attachment.png" OnCommand="ImageButton1_Command" CommandArgument='<%# Eval("Lebelle") %>' />
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
in the code behind
protected void ImageButton1_Command(object sender, CommandEventArgs e)
{
string newjob = e.CommandArgument.ToString().Split(',')[0];
}
Edit Data Binding
protected void Button1_Click(object sender, EventArgs e)
{
string newjob = tbAddMetier.Text;
Metier m = new Metier { Lebelle = newjob };
CurrentCandidat.Metier1.Add(m);
try
{
notrecontexte.SaveChanges();
}
catch
{
}
tbAddMetier.Text = "";
rptrMetier.DataSource = CurrentCandidat.Metier1;
rptrMetier.DataBind();
C_Compte.Update();
}
My problem is that the button clic event is never fired!!
What is the reason?
How can i fix my code?
Add Postback trigger for Button1 as mentioned below :
<asp:UpdatePanel ID="C_Compte" runat="server" UpdateMode="Conditional">
<ContentTemplate>
Métier:
<asp:TextBox ID="tbAddMetier" CssClass="Textboxes" Width="300px" Height="25px" runat="server"></asp:TextBox>
<asp:Button ID="btnAddMetier" runat="server" Text="Ajouter" CssClass="OffreEmploiSearch" OnClick="Button1_Click" />
<h4 style="font-weight: bold">Mes métiers</h4>
<asp:Repeater ID="rptrMetier" runat="server">
<ItemTemplate>
<div style="font: normal normal normal 14px/1.4em play, sans-serif; color: rgb(95, 94, 93); padding-left: 10px; line-height: 22px">
<strong><%# Eval("Lebelle") %></strong></a>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Design_Ressources/img/attachment.png" OnCommand="ImageButton1_Command" CommandArgument='<%# Eval("Lebelle") %>' />
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnAddMetier"/>
</Triggers>
</asp:UpdatePanel>
I have a search button in my page. When I click the button, a paged datalist will show up
with result. I want to use modalPopupExtender with Datalist and collection pager. Is it possible ? Here is the code i tried but it doesn't work :
<asp:Label ID="Label5" runat="server"></asp:Label>
<asp:ModalPopupExtender ID="Label1_ModalPopupExtender" runat="server" CancelControlID="btThoat"
DynamicServicePath="" Enabled="True" PopupControlID="Panel1" TargetControlID="Label5">
</asp:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server">
<div style="margin-left: 20px; padding-top: 50px">
<asp:Label ID="lbl_CS" runat="server" Text="Ca sĩ" ForeColor="#FF33CC" Font-Size="18"
Visible="True"></asp:Label>
<asp:DataList ID="DataList1" runat="server" BackColor="White" BorderColor="#CC9966"
BorderStyle="None" BorderWidth="1px" CellPadding="4" GridLines="Both" RepeatColumns="4"
OnItemDataBound="DataList1_ItemDataBound">
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<ItemStyle BackColor="White" ForeColor="#330099" />
<ItemTemplate>
<table>
<tr>
<td style="width: 10px">
<asp:RadioButton ID="rd_CS" runat="server" GroupName="Casi" Text='<%# Eval("MaCS")%>'
AutoPostBack="False"></asp:RadioButton>
</td>
<td style="width: 75px">
<asp:Image ID="Img_Casi" runat="server" ImageUrl='<%#Eval("Hinhanh")%>' Width="75px"
Height="75px" BorderColor="#66FF33" />
</td>
<td style="width: 50px">
<asp:Label ID="lbl_Ten" runat="server" Text='<%#Eval("TenCS")%>'></asp:Label>
</td>
<td style="width: 40px">
<asp:Label ID="lbl_Ngaysinh" runat="server" Text='<%#Eval("Ngaysinh")%>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
</asp:DataList>
<cc2:CollectionPager ID="CollectionPager1" runat="server" MaxPages="1000" PagingMode="QueryString"
BackNextDisplay="Buttons" QueryStringKey="Datalist1">
</cc2:CollectionPager>
</div>
</asp:Panel>
Code in c#:
bool Checkcs()
{
string cs = "select MaCS, Quocgia, TenCS, Hinhanh, Thongtin, cast(convert(char(11), Ngaysinh, 113) as char) as Ngaysinh from casi where tencs like N'%" + txt_CS.Text + "%'";
da = new SqlDataAdapter(cs, cnn);
dtSP = new DataTable();
cnn.Open();
da.Fill(dtSP);
cnn.Close();
CollectionPager1.PageSize = 8;
CollectionPager1.DataSource = dtSP.DefaultView;
CollectionPager1.BindToControl = DataList1;
DataList1.DataSource = CollectionPager1.DataSourcePaged;
DataList1.DataBind();
Label1_ModalPopupExtender.Show();
if (dtSP.Rows.Count != 0)
return true;
else
return false;
}
protected void img_CheckCS_Click(object sender, ImageClickEventArgs e)
{
Checkcs();
}
If it's impossible. Is there another way to do it ? If it's possible. Can you show me an example code ? Any help would be great.
This is Sample. Please refer with this
.modalBackground {
background-color: Gray;
filter: alpha(opacity=80);
opacity: 0.8;
z-index: 10000;
}
.modalPopupCss {
background-color: white;
border-width: 1px;
border-style: solid;
border-color: #0066B3;
padding: 3px;
}
ASPX
<div>
<asp:ModalPopupExtender BackgroundCssClass="modalBackground" ID="Label1_ModalPopupExtender" CancelControlID="Button2" runat="server" Enabled="True" PopupControlID="Panel1" TargetControlID="lbl_CS"></asp:ModalPopupExtender>
<asp:Panel ID="Panel1" CssClass="modalPopupCss" runat="server">
<div style="margin-left: 20px; padding-top: 50px">
<asp:Label ID="lbl_CS" runat="server" Text="" ForeColor="#FF33CC" Font-Size="18" Visible="True"></asp:Label>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
<asp:Button ID="Button2" runat="server" Text="Close" />
</div>
</asp:Panel>
<asp:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click" />
Aspx.Cs
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
dt.Columns.Add("ID");
dt.Columns.Add("Name");
dt.Columns.Add("State");
}
protected void Button1_Click(object sender, EventArgs e)
{
dt.Rows.Add("1", "Vignesh", "True");
GridView1.DataSource = dt;
GridView1.DataBind();
Label1_ModalPopupExtender.Show();
}
I encountered a problem where i add two ajax modal popup in a single page. This two modal popup each do different things. one is is create and one is for update. When two modal popup, my update button cannot be click ans execute the update codes. And when i remove my create modal popup, my updates work? Can anyone tell me how do i make two popup exist in the same page?
<!--Modal Popup: Create Topic-->
<cc1:modalpopupextender ID="ModalPopupExtender1" runat="server"
TargetControlID="btnShowPopup" PopupControlID="pnlCreatePopup"
CancelControlID="btnCancel" BackgroundCssClass="modalBackground">
</cc1:modalpopupextender>
<asp:Panel ID="pnlCreatePopup" runat="server" CssClass="createModalPopup">
<!--Modal Popup: Update Topic-->
<asp:Button ID="bnUpdateShow" runat="server" style="display:none;" />
<cc1:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="bnUpdateShow" PopupControlID="pnlpopup" CancelControlID="btnUpdateCancel" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlpopup" runat="server" CssClass="topicModalPopup">
I solved this hiding the ajax pop up inside a panel configured as visible=false. I fire the popUp in codeBehind. here is some code:
<asp:LinkButton runat="server" ID="lbCredits1" Font-Underline="true"
CausesValidation="false" OnClick="btMpeCredits_Click">Credits</asp:LinkButton>
|
<asp:LinkButton runat="server" ID="lbPrivacy2" Font-Underline="true"
CausesValidation="false" OnClick="btMpePrivacy_Click">Privacy</asp:LinkButton>
<%--AjaxPopUpExtenderArea--%>
<asp:Panel ID="pnlAjaxArea" runat="server" Visible="false">
<%--PrivacyMPE--%>
<%--I have to hide the link button referenced in the AjaxPopUpExtender. I will use a different button to show the pop up--%>
<div style="display:none;">
<asp:LinkButton runat="server" ID="lbPrivacy" Text="PRIVACY"/>
</div>
<asp:ModalPopupExtender ID="MpePrivacy" runat="server" TargetControlID="lbPrivacy"
PopupControlID="PnlPrivacy" BackgroundCssClass="modalBackground" >
</asp:ModalPopupExtender>
<asp:Panel runat="server" ID="PnlPrivacy" Height="500px" Width="600px" BorderStyle="Solid"
BorderColor="#1E549E" BorderWidth="3px" BackColor="#FFFFFF" ScrollBars="Auto">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<UcPrivacy:Privacy runat="server" ID="Privacy" />
</td>
</tr>
<tr>
<td align="center">
<asp:ImageButton ImageUrl="~/App_Themes/GfRegistrationPage/images/chiudi-btn.gif" runat="server" OnClick="btMpeClose"
CausesValidation="False" />
<br />
<br />
</td>
</tr>
</table>
</asp:Panel>
<%--CreditsMPE--%>
<div style="display:none;">
<asp:LinkButton runat="server" ID="lbCredits" Text="credits"/>
</div>
<asp:ModalPopupExtender ID="MpeCredits" runat="server" TargetControlID="lbCredits"
PopupControlID="PnlCredits" BackgroundCssClass="modalBackground" >
</asp:ModalPopupExtender>
<asp:Panel runat="server" ID="PnlCredits" Height="500px" Width="600px" BorderStyle="Solid"
BorderColor="#1E549E" BorderWidth="3px" BackColor="#FFFFFF" ScrollBars="Auto">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<UcCredits:Credits runat="server" ID="Credits" />
</td>
</tr>
<tr>
<td align="center">
<asp:ImageButton ImageUrl="~/App_Themes/GfRegistrationPage/images/chiudi-btn.gif" runat="server" OnClick="btMpeClose"
CausesValidation="False" />
<br />
<br />
</td>
</tr>
</table>
</asp:Panel>
</asp:Panel>
and here some code behind:
#region ModalPopUpS Privacy credits
protected void btMpePrivacy_Click(object sender, EventArgs e)
{
pnlAjaxArea.Visible = true;
AjaxControlToolkit.ModalPopupExtender modalPop = ((AjaxControlToolkit.ModalPopupExtender)(this.Master.FindControl("ContentPlaceHolder1").FindControl("MpePrivacy")));
modalPop.Show();
}
protected void btMpeCredits_Click(object sender, EventArgs e)
{
pnlAjaxArea.Visible = true;
AjaxControlToolkit.ModalPopupExtender modalPop = ((AjaxControlToolkit.ModalPopupExtender)(this.Master.FindControl("ContentPlaceHolder1").FindControl("MpeCredits")));
modalPop.Show();
}
protected void btMpeClose(object sender, EventArgs e)
{
pnlAjaxArea.Visible = false;
}
#endregion