CS代码如下:private string encode(string s)
{
int length = s.Length;
String[] encoder = new String[0x100];
StringBuilder buffer = new StringBuilder(length * 2); for (int i = 0; i < length; i++)
{
char c = s[i];
int j = (int)c;
if (j < 0x100 && encoder[j] != null)
{
buffer.Append(encoder[j]); // have a named encoding
buffer.Append(';');
}
else if (j < 0x80)
{
buffer.Append(c); // use ASCII value
}
else
{
buffer.Append("&#"); // use numeric encoding
buffer.Append((int)c);
buffer.Append(';');
}
} return buffer.ToString();}
/// <summary>
/// Prepares the string with seach summary information.
/// </summary>
protected string Summary
{
get
{
if (total > 0)
return "<b>" + this.Query + "</b>的搜索结果:<b>" + this.fromItem + " - " + this.toItem + "</b> 总计:<b>" + this.total + "</b> 条.(搜索用时: " + this.duration.TotalSeconds + " 秒)";
return "<b>" + this.Query + "</b>没有找到.";
}
}/// <summary>
/// Return search query or null if not provided.
/// </summary>
protected string Query
{
get
{
string query = this.Request.Params["q"];
if (query == String.Empty)
return null;
return ""+encode(query);
}
}
aspx文件:<asp:textbox id=TextBoxQuery runat="server" Width="312px" Text="<%# Query %>">
</asp:textbox>
<asp:button id="ButtonSearch" runat="server" Text="Search"></asp:button>
<P class="summary"><asp:label id=LabelSummary runat="server" Text="<%# Summary %>"></asp:label></P>
当打开页面查询时,同样获得Query。为什么会这样。textbox 显示:产品而label显示:产品没有找到.
请问:如何让textbox显示产品。ps:因为要从别的页面提交查询。所以进行要对查询参数进行重新编码,
{
int length = s.Length;
String[] encoder = new String[0x100];
StringBuilder buffer = new StringBuilder(length * 2); for (int i = 0; i < length; i++)
{
char c = s[i];
int j = (int)c;
if (j < 0x100 && encoder[j] != null)
{
buffer.Append(encoder[j]); // have a named encoding
buffer.Append(';');
}
else if (j < 0x80)
{
buffer.Append(c); // use ASCII value
}
else
{
buffer.Append("&#"); // use numeric encoding
buffer.Append((int)c);
buffer.Append(';');
}
} return buffer.ToString();}
/// <summary>
/// Prepares the string with seach summary information.
/// </summary>
protected string Summary
{
get
{
if (total > 0)
return "<b>" + this.Query + "</b>的搜索结果:<b>" + this.fromItem + " - " + this.toItem + "</b> 总计:<b>" + this.total + "</b> 条.(搜索用时: " + this.duration.TotalSeconds + " 秒)";
return "<b>" + this.Query + "</b>没有找到.";
}
}/// <summary>
/// Return search query or null if not provided.
/// </summary>
protected string Query
{
get
{
string query = this.Request.Params["q"];
if (query == String.Empty)
return null;
return ""+encode(query);
}
}
aspx文件:<asp:textbox id=TextBoxQuery runat="server" Width="312px" Text="<%# Query %>">
</asp:textbox>
<asp:button id="ButtonSearch" runat="server" Text="Search"></asp:button>
<P class="summary"><asp:label id=LabelSummary runat="server" Text="<%# Summary %>"></asp:label></P>
当打开页面查询时,同样获得Query。为什么会这样。textbox 显示:产品而label显示:产品没有找到.
请问:如何让textbox显示产品。ps:因为要从别的页面提交查询。所以进行要对查询参数进行重新编码,
解决方案 »
- C#里XMl用selectNode为什么总是读不到值??
- (如图)在devexpress中如何实现把子窗体的标签放在主窗体的工具栏中?
- 关于c#读二进制文件的疑惑?
- 哪里有开源的文本编辑控件下载
- 怎么DrawString竖着写
- 反射出TargetException 错误,请问何解?急,在线等,谢谢!!
- 谁知道这段api函数如何调用?我快疯掉了!!!
- Remoting高手请进
- 紧急求救!!!!! 500分 datagrid更新
- 请教:2个不同工程下的窗体a和b,要想在a里点击一下按钮谈出b窗体,该怎么做?怎么引用?
- 我是女生,有人说做测试没有前途,大家怎么认为?
- 600里加急!!DataGrid中插入一行的问题--在线等
一直用JAVA,
我现在把它换成:private string encode(string s)
{UTF8Encoding utf8 = new UTF8Encoding();
Byte[] encodedBytes = utf8.GetBytes(s);
return utf8.GetString(encodedBytes);
}