我的 searchresults.aspx 页面中有一个 .ascx 控件:
<asp:LinkButton id="LinkButton1"
Text="Click Me"
Font-Names="Verdana"
Font-Size="14pt" PostBackUrl="~/searchresults.aspx?type=topics"
runat="server"/>
但是当我点击它时,它会进行回发,但似乎没有发送 type=topics。有什么建议吗?
最佳答案
试用 HyperLink导航到另一个页面:
<asp:HyperLink NavigateUrl="~/searchresults.aspx?type=topics" />
来自 MSDN:
HyperLink A control that displays a link to another Web page.
关于 LinkButton类(class)页面:
If you want to link to another Web page when the control is clicked, consider using the HyperLink control.
编辑:回复评论
- 删除
PostBackUrl
来自LinkButton
- 添加
<asp:LinkButton OnClick="OnTopicsTypesEnabled" ... />
- 在后面的代码中 (
searchresults.aspx.cs
)
protected void OnTopicsTypesEnabled(object sender, EventArgs args)
{
// handle this particular case
}
关于c# - 在 ASP.NET 中对 LinkButton 使用 PostBack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7085361/