ASP.NET母版页中动态显示图像滑块问题 [英] Problem with display image slider dynamically in ASP.NET master page
问题描述
嗨
i想要在所有页面中显示滑块,所以我写了一个项目,从sql server数据库读取图像,并使用java脚本和src标签显示幻灯片。
一切正常,但是当我在母版页中使用该代码并且网页用户控件不起作用时
我尝试过:
母版页:
<%@ Master语言=C#AutoEventWireup = trueCodeFile =MasterPageTest.master.csInherits =MasterPageTest%>
< title>
< asp:contentplaceholder id =headrunat =server>
$(凭证).ready (function(){
InitializeImageSlider();
});
函数InitializeImageSlider(){
$ ('。flexlexlider')。flexslider({
an imation:slide,
controlNav:true,
directionNav:true,
itemWidth:100%,
itemHeight:400
});
}
.error,.notice,.success
{
填充:.8em;
margin-bottom:1em;
border:2px solid #ddd;
}
.error
{
背景:#FBE3E4;
颜色:#8a1f11;
border-color:#FBC2C4;
}
.notice
{
背景:#FFF6BF;
颜色:#514721;
border-color:#FFD324;
}
.success
{
背景:#E6EFC2;
颜色:#264409;
border-color:#C6D880;
}
.error a
{
颜色:#8a1f11;
}
。通知a
{
颜色:#514721;
}
。成功
{
颜色:#264409;
}
< asp:panel id =sliderPanelrunat =server>
hi
i want show slider in all pages so i write a project that read images fro sql server database and using java script and src tag to display slides.
all is ok but when i use that code in master page and web user control does not work
What I have tried:
master page:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPageTest.master.cs" Inherits="MasterPageTest" %>
<title>
<asp:contentplaceholder id="head" runat="server">
$(document).ready(function () {
InitializeImageSlider();
});
function InitializeImageSlider() {
$('.flexslider').flexslider({
animation: "slide",
controlNav: true,
directionNav: true,
itemWidth: "100%",
itemHeight: 400
});
}
.error, .notice, .success
{
padding: .8em;
margin-bottom: 1em;
border: 2px solid #ddd;
}
.error
{
background: #FBE3E4;
color: #8a1f11;
border-color: #FBC2C4;
}
.notice
{
background: #FFF6BF;
color: #514721;
border-color: #FFD324;
}
.success
{
background: #E6EFC2;
color: #264409;
border-color: #C6D880;
}
.error a
{
color: #8a1f11;
}
.notice a
{
color: #514721;
}
.success a
{
color: #264409;
}
<asp:panel id="sliderPanel" runat="server">
< asp:label text =上传图片(.jpeg / .jpg /。 png)runat =servervisible =false>
< asp:fileupload id =fluImagerunat =server可见=false>
< asp:button id =btn_Uploadrunat =servertext =Uploadonclick =btnUpload可见=false>
< asp:button id =Button2runat =servertext =刷新页面visible =false >
<asp:label text="Upload Image (.jpeg/.jpg/.png)" runat="server" visible="false">
<asp:fileupload id="fluImage" runat="server" visible="false">
<asp:button id="btn_Upload" runat="server" text="Upload" onclick="btnUpload" visible="false">
<asp:button id="Button2" runat="server" text="Refresh Page" visible="false">
< asp:contentplaceholder id =ContentPlaceHolder1 runat =server>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
cs代码:
使用系统;
使用系统.Collections.Generic;
使用System.IO;
使用System.Linq;
使用System.Web;
使用System.Web.UI;
使用System.Web.UI.WebControls;
公共部分类MasterPageTest:System.Web .UI.MasterPage
{
protected void Page_Load(object sender,EventArgs e)
{
LoadImage();
}
private void LoadImage()
{
尝试
{
string imagePath =〜/ Upload / BannerImage /;
string imageSource = SiteBaseUrl +Upload / BannerImage / ; $ / b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ string fileSlide = string.Empty;
string fileName = string.Empty;
DirectoryInfo di = new DirectoryInfo(PhotoFilePath);
FileInfo [] rgFiles = di.GetFiles(*。*);
foreach(文件信息在rgFiles中)
{
fileSlide = @
divSlider + = fileSlide;
}
divImageSlider.InnerHtml = divSlider +
cs code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MasterPageTest : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
LoadImage();
}
private void LoadImage()
{
try
{
string imagePath = "~/Upload/BannerImage/";
string imageSource = SiteBaseUrl + "Upload/BannerImage/";
string PhotoFilePath = Server.MapPath(imagePath);
string divSlider = @"