说明URL不是去codeD asp.net [英] Description url not being decoded asp.net
本文介绍了说明URL不是去codeD asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每当我我descprtion网址绑定到数据源它会评估项目,但在两者之间增加了这些奇怪的%20。
即。
果冻%20fish
这code完美的作品时我的形象我的title属性即
<立GT;< ASP:直放站ID =Repeater1=服务器><&ItemTemplate中GT;
< ASP:图片ID =Image1的=服务器的ImageUrl ='<%#+的eval(ID)%GTgetImage.ashx IMID =?;标题='<%#的eval(imagename)%>'的descriptionUrl ='<%#的eval(说明)%GT;' />
< / ItemTemplate中>
< / ASP:直放站>< /李>
我如何去code本的descriptionUrl?
下面是我的C#code:
SqlConnection的连接=新的SqlConnection(STRCON);
字符串查询字符串=选择图片,说明imagename,从表id其中STARTDATE< = CONVERT(日期,SYSDATETIME())和endate> = CONVERT(日期,SYSDATETIME()); 的SqlCommand命令=新的SqlCommand(查询字符串,连接); SqlDataAdapter的daimages =新SqlDataAdapter的(命令);
DataTable的DT =新的DataTable();
daimages.Fill(DT);
Repeater1.DataSource = DT; Repeater1.DataBind();
解决方案
一个空间的变EN codeD为%20
在URL中 - 这是一个特殊字符在URL中。
在code是做正确的事。
Whenever I bind my descprtion url to the datasource it evaluates the item, but adds these weird "%20" in between.
I.E.
jelly%20fish
this code works perfectly when in my title attribute of my image i.e.
<li><asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "getImage.ashx?ImID="+ Eval("ID") %>' title='<%# Eval("imagename") %>' DescriptionUrl='<%# Eval("Description") %>' />
</ItemTemplate>
</asp:Repeater></li>
How do i decode this descriptionurl?
Here is my c# code:
SqlConnection connection = new SqlConnection(strcon);
string querystring = "SELECT image, description ,imagename, id from table where startdate <= CONVERT (date, SYSDATETIME())and endate >= CONVERT (date, SYSDATETIME())";
SqlCommand command = new SqlCommand(querystring, connection);
SqlDataAdapter daimages = new SqlDataAdapter(command);
DataTable dt = new DataTable();
daimages.Fill(dt);
Repeater1.DataSource = dt;
Repeater1.DataBind();
解决方案
A space gets encoded as %20
in a URL - it is a special character in a URL.
The code is doing the right thing.
这篇关于说明URL不是去codeD asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文