This commit is contained in:
夏菊 2025-03-03 10:53:04 +08:00
parent ac3e368d1f
commit 4d9b7e2b79
5 changed files with 54 additions and 10 deletions

View File

@ -516,5 +516,28 @@ namespace BLL
return result;
}
/// <summary>
/// 判断文件类型是否是图片
/// </summary>
/// <param name="FiletExtension"></param>
/// <returns></returns>
public static bool IsImage(string FiletExtension)
{
bool result = false;
List<String> list = new List<string>();
list.Add(".png");
list.Add(".jpg");
list.Add(".jpeg");
foreach (var item in list)
{
if (item == FiletExtension)
{
result = true;
break;
}
}
return result;
}
}
}

View File

@ -10,17 +10,19 @@
<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" AutoSizePanelID="TabStrip1" runat="server" />
<f:TabStrip ID="TabStrip1" IsFluid="true" ShowBorder="true" ActiveTabIndex="0"
<f:TabStrip ID="TabStrip1" IsFluid="true" ShowBorder="true" ActiveTabIndex="0" Hidden="true"
runat="server">
<Tabs>
<f:Tab ID="Tab1" EnableIFrame="true"
<Tabs>
<f:Tab ID="Tab1" EnableIFrame="true" Width="12000px"
Title="预览" runat="server">
</f:Tab>
</Tabs>
</f:TabStrip>
<f:Button ID="btnClose" EnablePostBack="false" ToolTip="关闭" hidden="true" Text="关闭" runat="server" Icon="SystemClose" Size="Medium">
<f:Button ID="btnClose" EnablePostBack="false" ToolTip="关闭" Hidden="true" Text="关闭" runat="server" Icon="SystemClose" Size="Medium">
</f:Button>
<iframe id="LookHtml" runat="server" width="700" height="600" name="LookHtml" hidden="hidden"></iframe>
<iframe id="LookHtml" runat="server" width="700" height="600" name="LookHtml" hidden="hidden"></iframe>
<f:Image ID="Image1" runat="server" ImageMinWidth="1000px" Icon="World" Hidden="true">
</f:Image>
</form>
</body>
</html>

View File

@ -22,7 +22,7 @@ namespace FineUIPro.Web.AttachFile
{
newurl = Baseurl + Fileurl;
}
else if (FiletExtension == ".txt"|| FiletExtension== "pdf")
else if (FiletExtension == ".txt" || FiletExtension == "pdf")
{
newurl = Fileurl;
}
@ -30,9 +30,19 @@ namespace FineUIPro.Web.AttachFile
{
newurl = Fileurl;
}
this.LookHtml.Src = newurl;
this.Tab1.IFrameUrl = newurl;
if (AttachFileService.IsImage(FiletExtension))
{
this.TabStrip1.Hidden = true;
this.Image1.Hidden = false;
this.Image1.ImageUrl = newurl;
}
else
{
this.TabStrip1.Hidden = false;
this.Image1.Hidden = true;
this.LookHtml.Src = newurl;
this.Tab1.IFrameUrl = newurl;
}
//StreamReader fread = new StreamReader(url, System.Text.Encoding.GetEncoding("gb2312"));
//string ss = fread.ReadToEnd();
//Response.Write(ss);

View File

@ -67,5 +67,14 @@ namespace FineUIPro.Web.AttachFile
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlIframe LookHtml;
/// <summary>
/// Image1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Image Image1;
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />
<IISExpressSSLPort />