62,052
社区成员
发帖
与我相关
我的任务
分享
<form id="form1" runat="server">
<div>
<div>
<div id="div1"
style ="position :absolute; top: 21px; left: 19px; height: 440px; width: 174px;">
<asp:TextBox ID="txtlike" runat="server" Height="17px" Width="162px"></asp:TextBox>
<asp:Button ID="btnFind"
runat="server" Text="临床表现" Height="18px" Width="166px"
onclick="btnFind_Click" />
<asp:ListBox ID="lbFourDiagnostic" runat="server" Height="407px" Width="165px"
AutoPostBack="True"
onselectedindexchanged="lbFourDiagnostic_SelectedIndexChanged"></asp:ListBox>
</div>
<div id="div2" style ="position:absolute; top: 23px; left: 196px; width: 488px;">
<table style="width: 512px" >
<tr><td class="style1"> 四诊 </td><td>
<asp:Label ID="lbFour" runat="server" Text="">望</asp:Label>
</td></tr>
<tr><td class="style1">诊断类型</td><td>
<asp:TextBox ID="txtType" runat="server" Height="32px" Width="406px"></asp:TextBox></td></tr>
<tr><td class="style1">诊断部位</td><td>
<asp:TextBox ID="txtdiagnoseParts" runat="server" Height="32px" Width="406px"></asp:TextBox></td></tr>
<tr><td>症状</td><td>
<asp:TextBox ID="txtzhengzhuang" runat="server" Height="36px" Width="403px"></asp:TextBox></td></tr>
<tr><td>症候</td><td>
<asp:TextBox ID="txtzhenghou" runat="server" Height="35px" Width="403px"></asp:TextBox></td></tr>
<tr><td class="style1">临床表现</td><td>
<asp:TextBox ID="txtmanifestation" runat="server" Height="72px"
TextMode="MultiLine" Width="405px"></asp:TextBox></td></tr>
<tr><td class="style1">临床意义</td><td>
<asp:TextBox ID="txtsignification" runat="server" Height="78px"
TextMode="MultiLine" Width="403px"></asp:TextBox></td></tr>
<tr><td class="style1">关键字注释</td><td>
<asp:TextBox ID="txtKeywordNote" runat="server" Height="78px"
TextMode="MultiLine" Width="403px"></asp:TextBox></td></tr>
<tr>
<td >图片:</td>
<td>
<asp:FileUpload ID="fpImage" runat="server" Width="303px"
onchange="ShowImage(this)" name="file1" />
</td>
</tr>
<tr>
<td align="center" colspan="2">
<img id="images" alt="" height="100px" width="100px"/>
</td>
</tr>
</table>
<table style="width: 475px"><tr><td>
<asp:LinkButton ID="btnTongyici" PostBackUrl="~/BaseData/TongYiCi.aspx"
runat="server" onclick="btnTongyici_Click">添加同义词</asp:LinkButton>
</td><td>
<asp:Button ID="btnDelete" runat="server" Text="删除" onclick="btnDelete_Click"
style="height: 26px"/></td><td>
<asp:Button ID="btnUpdate" runat="server" Text="修改" onclick="btnUpdate_Click"/></td><td>
<asp:Button ID="btnAdd" runat="server" Text="添加" Height="26px"
onclick="btnAdd_Click" Width="40px"/></td>
</td><td><asp:Button ID="btnImage" runat="server" Text="添加图片"
onclick="btnImage_Click" /></td></tr></table>
</div>
</div>
</div>
</form>
</body>
</html>
<script type="text/javascript">
var newPath = "";
var filePath = "";
function ShowImage(obj) {
filePath = obj.value;
CallServer(obj.value, ' ');
}
//在page_load中的“注册回调脚本”
function ReceiveServerData(rValue) {
newPath = rValue;
//CreateImagetoImg();
//显示图片
document.getElementById("images").src = newPath;
}
</script>
protected void Page_Load(object sender, EventArgs e)
{
string sbScript = ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");
if (!ClientScript.IsClientScriptBlockRegistered("CallServer"))
{
string cbScript = @"function CallServer(arg,context){" + sbScript + "}";
ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", cbScript, true);
}
}
#region ICallbackEventHandler 成员
public string GetCallbackResult()
{
try
{
string fileName = System.IO.Path.GetFileName(returnValue);
string imgPath = Server.MapPath("ImageFiles/");
string fullPath = imgPath + fileName;//完整的路径
Stream s = File.OpenRead(returnValue);//读取文件
byte[] buffer = new byte[s.Length];
s.Read(buffer, 0, (int)s.Length);
int len = (int)s.Length;
s.Dispose();
s.Close();
FileStream stream = new FileStream(fullPath, FileMode.Create);
stream.Write(buffer, 0, len);
Bitmap map = new Bitmap(stream);
if (System.IO.Path.GetExtension(returnValue).Equals("gif"))
{
map.Save(stream, ImageFormat.Gif);
}
else if (System.IO.Path.GetExtension(returnValue).Equals("jpg"))
{
map.Save(stream, ImageFormat.Jpeg);
}
map.Dispose();
stream.Dispose();
stream.Close();
return "ImageFiles/" + fileName;
}
catch (Exception e)
{
return null;
}
}
public void RaiseCallbackEvent(string eventArgument)
{
try
{
if (!string.IsNullOrEmpty(eventArgument))
{
string fileName = eventArgument.Substring(eventArgument.LastIndexOf("\\") + 1);//获取文件名称
string geshi = fileName.Substring(fileName.LastIndexOf('.') + 1);//获取文件格式
//执行绘制缩略图
System.Drawing.Image image = MakeThumbnail(eventArgument, "ImageFiles/" + time + fileName, 100, 100);
//image.Save("/ImageFiles/" + time + fileName);
//image.Save(Server.MapPath("ImageFiles/") + time + fileName);
eventArgument = Server.MapPath("ImageFiles/") + time + fileName;
//eventArgument = "ImageFiles/" + time + fileName;
image.Dispose();
returnValue = eventArgument;
}
}
catch (Exception e)
{
;
}
}
/// <summary>
/// 生成缩略图
/// </summary>
/// <param name="sPath">原图片的路径</param>
/// <param name="newSPath">新生成的图片的路径</param>
/// <param name="newWidth">生成缩略图的宽度</param>
/// <param name="newHeight">生成缩略图的高度</param>
/// <returns>缩略图</returns>
public System.Drawing.Image MakeThumbnail(string sPath, string newSpath, int newWidth, int newHeight)
{
try
{
System.Drawing.Image sImage = System.Drawing.Image.FromFile(sPath);
//保存要生成的缩略图的宽度和高度
int nw = newWidth;
int nh = newHeight;
//原始图片的高度和宽度
int sw = sImage.Width;
int sh = sImage.Height;
//如果原始宽度大于缩略图的宽度
if (sw > nw)
{
sw = nw;
}
//如果原始高度大于缩略图的高度
if (sh > sw)
{
sh = sw;
}
sImage = new System.Drawing.Bitmap(sPath);//绘制原路径的图片
System.Drawing.Bitmap sNewImage = new System.Drawing.Bitmap(sImage, sw, sh);//绘制新图片
sNewImage.Save(newSpath);
sImage.Dispose();
sNewImage.Dispose();
return sNewImage;
}
catch (Exception e)
{
return null;
}
}