如题。
在Ie下,<%=str%>可以获得后台的字符串。但是在FF下面,就不行。谁知道为什么?难道在FF还有一个写法么? <asp:HiddenField ID="hideURL" runat="server" Value="<%=fileURL %>" /> public string fileURL = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (GetCookie("fileURL") != "")
{
fileURL = GetCookie("fileURL");
}
}跪求,高手解答。
在Ie下,<%=str%>可以获得后台的字符串。但是在FF下面,就不行。谁知道为什么?难道在FF还有一个写法么? <asp:HiddenField ID="hideURL" runat="server" Value="<%=fileURL %>" /> public string fileURL = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (GetCookie("fileURL") != "")
{
fileURL = GetCookie("fileURL");
}
}跪求,高手解答。
protected void Page_Load(object sender, EventArgs e)
{
if (GetCookie("fileURL") != "")
{
fileURL = GetCookie("fileURL");
}
}
你在ff下查看html源码了吗?
private string fileURL;
public string FileURL
{
get{retrun ViewState["FileUrl"]}
set{value = ViewState["FileUrl"].ToString()}
}
protected void Page_Load(object sender, EventArgs e)
{
if (GetCookie("fileURL") != "")
{
fileURL = GetCookie("fileURL");
this.FileUrl = fileURL;
}
}
<asp:HiddenField ID="hideURL" runat="server" Value="<%=FileURL %>" />
public string FileURL
{
get{return ViewState["FileUrl"]}
set{value = ViewState["FileUrl"].ToString()}
}
protected void Page_Load(object sender, EventArgs e)
{
if (GetCookie("fileURL") != "")
{
fileURL = GetCookie("fileURL");
ViewState["FileUrl"] = fileURL;
}
}
行 15: get
行 16: {
行 17: return ViewState["fileURL"].ToString();
行 18: }
行 19: set其实前台html代码就那一句话是用到的,其他可以忽略-。-
hideURL.Value= GetCookie("fileURL");就可以了
前段输出html//这是获取后台字符串的隐藏控件
<input id="hideURL" type="hidden" name="hideURL"><div id="ext-gen1013" class="x-panel-body x-panel-body-default x-panel-body-default x-docked-noborder-right x-docked-noborder-bottom x-docked-noborder-left x-layout-fit" style="height: 664px; left: 0px; top: 0px;">
<div id="shouye" class="x-panel x-tabpanel-child x-panel-default" role="presentation" style="height: 664px; width: 1237px;">
//这是设置背景图片的div.
<div id="ext-gen1029" class="x-panel-body x-panel-body-default x-panel-body-default" style="background-image: url("/CustomFileUpload/"); height: 663px; left: 0px; top: 0px;"></div>无语了
text: '上传',
type: 'submit',
handler: function () {
//关键在这。我是用ajax异步提交一个处理页面
if (!imgform.form.isValid()) { return; }
imgform.form.submit({
waitMsg: '正在设置...',
url: 'CustomFileUpload/FileUploadField.aspx',
success: function (form, action) {
win.hide();
}
});
},
failure: function (form, action) {
form.reset();
if (action.failureType == Ext.form.Action.SERVER_INVALID) {
Ext.Message.alert('警告', action.result.errors.msg);
}
}
},
{
text: '关闭',
type: 'submit',
handler: function () {
win.close(this);
}
}]处理页面 codeprotected void Page_Load(object sender, EventArgs e)
{
string fileName = string.Empty;
string fileURL = string.Empty;
string rt = string.Empty;
try
{
HttpPostedFile file = Request.Files[0];//上载文件
fileName = GetFullName(file.FileName);//获取文件的名称
file.SaveAs(Server.MapPath("upload\\" + fileName));//存储路径
fileURL = "upload/" + fileName;//获取路径
rt = "{success:'true',fileURL:'" + fileURL + "'}";//成功标记
//设置cookie
SetCookie("fileURL", fileURL, 527040);
}
catch
{
rt = "{success:'false',fileURL:'" + fileURL + "'}";//失败标记
}
Response.Write(rt);
}
/// <summary>
/// 获取文件名称
/// </summary>
/// <param name="fullName">文件全名称</param>
/// <returns>文件名称</returns>
private string GetFullName(string fullName)
{
string fileName = string.Empty;
int last = fullName.LastIndexOf(@"\");
fileName = fullName.Substring(last + 1, fullName.Length - last - 1);
return fileName;
}
/// <summary>
/// 写cookie的值
/// </summary>
/// <param name="name">名称</param>
/// <param name="value">值</param>
/// <param name="expires">过期时间</param>
public static void SetCookie(string name, string value,int expires)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[name];//获取当前上下文请求的cookie值
//判断当前cookie是否为空,如果为空,从新创建一个cookie
if (cookie == null)
{
cookie = new HttpCookie(name);
}
cookie.Value = value;
//设置cookie过期时间
cookie.Expires = DateTime.Now.AddMinutes(expires);
//将cookie添加到当前的回传中
HttpContext.Current.Response.AppendCookie(cookie);
}
}显示页面获取cookie code public string fileURL = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (GetCookie("fileURL") != "")
{
fileURL = GetCookie("fileURL");
}
}
/// <summary>
/// 获取cookie的值
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public static string GetCookie(string name)
{
//判断当前上下文的cookie是否为空
if (HttpContext.Current.Request.Cookies != null & HttpContext.Current.Request.Cookies[name] != null)
{
//返回当前上下文cookie的值0
return HttpContext.Current.Request.Cookies[name].Value.ToString();
}
return "";
}各位大仙,看看,哪里的错?对于cookie对浏览器的兼容,小弟还是一知半解-。-
还有control的处理模型?有这理论?
control的处理模型?跟这个没关系
request["hideURL"]
我只知道有个办法,添加一段css但是只支持IE部支持FF。
支持IEfilter: progid:dximagetransform.microsoft.alphaimageloader(src='1.gif', sizingmethod='scale');怎么才能兼容IE和FF呢。是不是得用js去控制?