Server.Transfer只能实现本域名下面的,
但要实现Server.Transfer("http://www.csdn.net/logo.jpg")
那位大哥有答案呀!
谢谢各位,搞定了,我最后是这样做的!
WebClient wc = new WebClient();
byte[] imgdata = wc.DownloadData("http://community.csdn.net/images/CSDN_logo.GIF");
//Stream sr = new MemoryStream();
Response.BinaryWrite(imgdata);
2.
http://www.percyboy.com/w/ftb/
FreeTextBox 1.6.3 (中文版)
JS社区的"梅花雪"日历控件很不错.
http://www.meizz.com/Web/Download/Web_Calendar_30.rar
3.调用System里的方法时不但有方法的定义提示还有一行中文说明。
调用自己写的方法时如何写让它也能出现一行中文的说明?
如果在同一个项目中使用的话,直接就能正常显示了,如果你编译成了dll,在其他项目中引用的话,还需要在生成前的项目中设置生成xml文件,然后编译生成相应的xml文件,在使用时将xml文件拷到引用dll的相同目录下(一般是bin)。这样你就能看到函数说明了。
4
url传递中文的解决方案
1.设置web.config文件。(我不喜欢设置成这样)
<system.web>
......
<globalization requestEncoding="gb2312" respon_seEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312" />
......
</system.web>
2.传递中文之前,将要传递的中文参数进行编码,在接收时再进行解码。
>> 进行传递
string Name = "中文参数";
Response.Redirect("B.aspx?Name="+Server.UrlEncode(Name));
>> 进行接收
string Name = Request.QueryString["Name"];
Response.Write(Server.UrlDecode(Name));
3.如果是从 .HTML 文件向 .Aspx 文件进行传递中文参数的话(即不从后台用 Redirect()方法进行 Url 转换)。一样要将传递的中文参数进行编码,在接收时再进行解码。
>> 进行传递
<script language="JavaScript">
function GoUrl()
{
var Name = "中文参数";
location.href = "B.aspx?Name="+escape(Name);
}
</script>
<body on_click="GoUrl()">
>> 进行接收
string Name = Request.QueryString["Name"];
Response.Write(Server.UrlDecode(Name));
一般来说。设置web.config文件就可以了。但是如果你用 JavaScript 调用 webservice 方法的话(往webservice里面传递中文参数)。设置 web.config 文件好象无效。
5. 寻求:用正则表达匹配并替换输入字符串中的全角字符为半角字符?
非要用正则表达式吗?下面这段代码就是全角转半角的
public static string CharConverter(string source)
{
System.Text.StringBuilder result = new System.Text.StringBuilder(source.Length, source.Length);
for (int i=0; i<source.Length; i++)
{
if (source[i] >= 65281 && source[i] <= 65373)
{
result.Append((char)(source[i] - 65248));
}
else if (source[i] == 12288)
{
result.Append(' ');
}
else
{
result.Append(source[i]);
}
}
return result.ToString();
}
this.txt.Attributes.Add("onchange","WideCharToChar()");
js实现半全角转换
function WideCharToChar(){
c =event.srcElement.value;
myArray= new Array();
for(i=0;i<c.length;i++)
{
if(c.charCodeAt!=null&&String.fromCharCode!=null)
{
var charCode=c.charCodeAt(i);
if(charCode>0xfee0){
myArray[i]=String.fromCharCode(charCode-0xfee0);
}
else
myArray[i]=String.fromCharCode(charCode);
}
}
event.srcElement.value=str;
}
在DataGrid中模板列绑定了两个DropDownList怎样实现联动? 2005-10-04
http://community.csdn.net/Expert/topic/4308/4308266.xml?temp=.9335291
add a SelectedIndexChanged event handler for your first dropdownlist in the DataGrid's ItemCreated event handler
protected void DataGrid1_ItemCreated(Object sender, DataGridItemEventArgs e)
{
if ( e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
DropDownList ddl = e.Item.FindControl("DDL1") as DropDownList;
ddl.SelectedIndexChanged += new EventHandler(DDL_SelectedIndexChanged);
}
}
void DDL_SelectedIndexChanged(object sender,EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
DataGridItem dgi = (DataGridItem)ddl.Parent.Parent;
DropDownList ddl2 = dgi.FindControl("DDL2") as DropDownList;
//....
}
(方法二)
<asp:TemplateColumn HeaderText="学院">
<ItemTemplate>
<asp:DropDownList ID="dep2" Runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"></asp:DropDownList>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="dep" Runat="server"></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
在前台直接加上事件DropDownList2_SelectedIndexChanged
然后在后台添加事件就可以了
protected void DropDownList2_SelectedIndexChanged(object sender, System.EventArgs e)
{
Response.Write(((DropDownList)sender).SelectedItem);
}
日期随机数
UploadFileName = UploadFile.PostedFile.FileName;
//UploadFileName = UploadFileName.Substring(UploadFileName.LastIndexOf("\\")+1);
//设置文件名按照日期和随机数字取名字
string fileExtra = UploadFileName.Substring(UploadFileName.LastIndexOf(".")+1);
System.Random random = new System.Random();
UploadFileName = System.DateTime.Now.ToString("yyyyMMddhhmmss") +random.Next(1000).ToString() +"."+ fileExtra;
c#中的日期差额:DateDiff在VB中有.
using System.TimeSpan:
DateTime dt = ...
DateTime d2 = ...
TimeSpan ts = dt - dt2;
n = ts.Hours;
DataGrid的行鼠标移动过的时候变化颜色,删除确认(backgroundColor区别大小写)
private void DgMoble_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
LinkButton lbtn = (LinkButton) e.Item.FindControl("LbtnDel");
if (lbtn != null)
{
lbtn.Attributes.Add("onclick","return confirm('确实删除吗?');");
}
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='#BFDFFF'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=''");
}
下载文件出现提示框或者直接显示在浏览器中
http://tb.blog.csdn.net/TrackBack.aspx?PostId=480802
出现提示框
string strFile="F:\\a.doc";//路径根据实际情况而定
if(!System.IO.File.Exists(strFile))
{
Response.Write("<script language='javascript'>alert('对不起,文件不存在!');</script>");
return;
}
Response.Clear();
Response.ClearHeaders();
Response.Charset = "GB2312";
Response.ContentEncoding =System.Text.Encoding.UTF8;
Response.ContentType = "application/octet-stream";
FileInfo fi=new FileInfo(strFile);
Response.AddHeader("Content-Disposition","attachment; filename=" + HttpUtility.UrlEncode(fi.Name)) ;
Response.AddHeader("Content-Length",fi.Length.ToString());
byte[] tmpbyte=new byte[1024*8];
FileStream fs=fi.OpenRead();
int count;
while((count=fs.Read(tmpbyte,0,tmpbyte.Length))>0)
{
Response.BinaryWrite(tmpbyte);
Response.Flush();
}
fs.Close();
Response.End();
直接在浏览器中打开
string strFile="F:\\a.doc";//路径根据实际情况而定
Response.Clear();
Response.ClearHeaders();
Response.Charset = "GB2312";
Response.ContentEncoding =System.Text.Encoding.UTF8;
Response.ContentType = "application/msword";
Response.WriteFile(strFile);
DataLis里的CheckBOx 和指定<FooterTemplate>里的button的事件 2006-02-16
private void DataList1_ItemCreated(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Footer)
{
Button btn = (Button) e.Item.FindControl("BtnSure");
if(btn != null)
{
btn.Click +=new EventHandler(BtnSure_Click);
}
}
}
private void BtnSure_Click(object send,EventArgs e)
{
string strMobiles = "";
foreach(DataListItem item in DataList1.Items)
{
CheckBox cbx = (CheckBox) item.FindControl("CbxMobile");
Label lbl = (Label) item.FindControl("LblCarId");
if(cbx != null && lbl != null && cbx.Checked == true)
{
if(strMobiles == "")
{
strMobiles = lbl.Text.Trim();
}
else
{
strMobiles += ","+lbl.Text.Trim();
}
}
}
Response.Write("选择的项目:"+strMobiles);
}
Form里增加对象的方法
private void Page_Init(object sender, EventArgs e)
{
//Iterate through the control collection for the page
foreach (Control objControl in ((Page)sender).Controls)
{
if (objControl is HtmlForm)
{
HtmlForm objForm = (HtmlForm)objControl;
//Instantiate and add the control to the page
//using the .ASCX file
objForm.Controls.AddAt(0,
objForm.Page.LoadControl("Header.ascx"));
objForm.Controls.Add(objForm.Page.LoadControl("Footer.ascx"));
break;
}
}
}
导出到excel乱码的问题
Response.Write("<meta http-equiv=Content-Type content=text/html;charset=gb2312>")
日期绑定
<asp:BoundField DataField="START_DATE" HeaderText="结束时间" DataFormatString="{0:yyyy-MM-dd}"
HtmlEncode="False" >
<itemstyle horizontalalign="Center" />
<headerstyle horizontalalign="Center" />
</asp:BoundField>
<asp:Label id="LblSunday" runat="server" Text='<%# Bind("Sunday_Date","{0:dd}") %>'></asp:Label>
<asp:Label id="LblSunday2" runat="server" Text='<%# MakeDate(Eval("Sunday_Date")) %>'></asp:Label> (但<%# MakeDate(Bind("Sunday_Date")) %>是不可以的.)
this.Label1.Text = DateTime.Now.ToString("dd");
http://www.chinapoesy.com
诗词在线 |唐诗|宋词|元曲|现代诗歌|外国诗歌
126在线阅读网
http://www.Read126.cn
126在线阅读网 人物传记、古典名著、历史书籍。。。
浙公网安备 33010602011771号