链接到单选按钮选择,asp.net c#

发布于 2024-10-13 08:25:44 字数 1557 浏览 5 评论 0原文

寻找答案来拯救世界。

我有一个“文章”页面,其中包含单选按钮列表和文本区域。当用户选择单选按钮时,文本区域将被填充。现在用户希望能够通过 url 链接指向一篇文章。 (一切都是动态的,并且是从数据库源中提取的)

通过使用第 3 方工具,我能够获取将链接到用户选择的确切 http 请求(如下)。问题是网址非常长。还有另一种方法可以链接到单选按钮选择吗?这样我就可以修改查询字符串以适应特定的格式。谢谢。

特定单选按钮选择的 url --------------

http://localhost:60062/test/test_articles.aspx?__EVENTTARGET=ctl00%24MainContent%24RadioButtonList1%243&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=%2FwEPDwULLTEyMjYyNjEzNjcPZBYCZg9kFgICAw9kFgoCAQ8PZA8QFgFmFgEWAh4OUGFyYW1ldGVyVmFsdWUFFmh0dHA6Ly9sb2NhbGhvc3Q6NjAwNjIWAQIFZGQCBw9kFgICAw8PFgIeBFRleHQFATBkZAIJDzwrAA8CAA8WBB4LXyFEYXRhQm91bmRnHgtfIUl0ZW1Db3VudAIBZAoQFgAWABYAFgJmD2QWBmYPDxYCHgdWaXNpYmxlaGRkAgEPZBYCZg9kFgJmDxUBRUFzayB5b3VyIGtpZHMsICJ3aGF0IHdlcmUgdGhlIHRocmVlIGJlc3QgdGhpbmdzIHRoYXQgaGFwcGVuZWQgdG9kYXk%2FImQCAg8PFgIfBGhkZAILDw9kDxAWAWYWARYCHwBkFgECA2RkAhMPZBYIAgEPPCsADwIADxYEHwJnHwNmZAoQFgAWABYAZAIDDw9kDxAWAWYWARYCHwBlFgFmZGQCBQ8PZA8QFgFmFgEWAh8AZBYBAgNkZAIHDxAPFgIfAmdkEBUFAzQ0NAJmZgMzMzMBMwR0ZXN0FQUBOAE5AjE0AjE1AjMzFCsDBWdnZ2dnZGQYBAUUY3RsMDAkTmF2aWdhdGlvbk1lbnUPD2QFCVxBcnRpY2xlc2QFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYCBRhjdGwwMCRMb2dpblN0YXR1czEkY3RsMDEFGGN0bDAwJExvZ2luU3RhdHVzMSRjdGwwMwUSY3RsMDAkRGV0YWlsc1ZpZXcyDxQrAAdkZGRkZBYAAgFkBR5jdGwwMCRNYWluQ29udGVudCREZXRhaWxzVmlldzMPZ2Sn7TStsoTOeJn0xoyHzh41vo%2ByiD%2Ff2wmeKTuUwe9Ing%3D%3D&__EVENTVALIDATION=%2FwEWCQKVn9%2FvDwLh8vmTCALk7M7lDQKp6JekDwKm6JekDwK%2B6OenDwK%2B6OunDwK86OOnDwKxh73KAwOihkx44beFhpVDoerFt%2BLYkev3csEzPfS6PI4lPJbP&ctl00%24MainContent%24RadioButtonList1=15

on the search for an answer to save the day.

I have an "articles" page that holds a radiobutton list and a textarea. when the user selects a radio button, the text area is populated. now the users wants to be able to point to an article via a url link. (everything is dynamic and being pulled from a db source)

by using a 3 party tool i was able to grab the exact http request (below) that will link to the users' selection. the problem is the url is extremely long. is there another way to link to the radio button selection? that way i can just modify the query string to fit a specific format. thanks.

url to specfic radio button selection ---------------

http://localhost:60062/test/test_articles.aspx?__EVENTTARGET=ctl00%24MainContent%24RadioButtonList1%243&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=%2FwEPDwULLTEyMjYyNjEzNjcPZBYCZg9kFgICAw9kFgoCAQ8PZA8QFgFmFgEWAh4OUGFyYW1ldGVyVmFsdWUFFmh0dHA6Ly9sb2NhbGhvc3Q6NjAwNjIWAQIFZGQCBw9kFgICAw8PFgIeBFRleHQFATBkZAIJDzwrAA8CAA8WBB4LXyFEYXRhQm91bmRnHgtfIUl0ZW1Db3VudAIBZAoQFgAWABYAFgJmD2QWBmYPDxYCHgdWaXNpYmxlaGRkAgEPZBYCZg9kFgJmDxUBRUFzayB5b3VyIGtpZHMsICJ3aGF0IHdlcmUgdGhlIHRocmVlIGJlc3QgdGhpbmdzIHRoYXQgaGFwcGVuZWQgdG9kYXk%2FImQCAg8PFgIfBGhkZAILDw9kDxAWAWYWARYCHwBkFgECA2RkAhMPZBYIAgEPPCsADwIADxYEHwJnHwNmZAoQFgAWABYAZAIDDw9kDxAWAWYWARYCHwBlFgFmZGQCBQ8PZA8QFgFmFgEWAh8AZBYBAgNkZAIHDxAPFgIfAmdkEBUFAzQ0NAJmZgMzMzMBMwR0ZXN0FQUBOAE5AjE0AjE1AjMzFCsDBWdnZ2dnZGQYBAUUY3RsMDAkTmF2aWdhdGlvbk1lbnUPD2QFCVxBcnRpY2xlc2QFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYCBRhjdGwwMCRMb2dpblN0YXR1czEkY3RsMDEFGGN0bDAwJExvZ2luU3RhdHVzMSRjdGwwMwUSY3RsMDAkRGV0YWlsc1ZpZXcyDxQrAAdkZGRkZBYAAgFkBR5jdGwwMCRNYWluQ29udGVudCREZXRhaWxzVmlldzMPZ2Sn7TStsoTOeJn0xoyHzh41vo%2ByiD%2Ff2wmeKTuUwe9Ing%3D%3D&__EVENTVALIDATION=%2FwEWCQKVn9%2FvDwLh8vmTCALk7M7lDQKp6JekDwKm6JekDwK%2B6OenDwK%2B6OunDwK86OOnDwKxh73KAwOihkx44beFhpVDoerFt%2BLYkev3csEzPfS6PI4lPJbP&ctl00%24MainContent%24RadioButtonList1=15

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

2024-10-20 08:25:44

无需传递 ViewState。您需要做的就是在 QueryString 中放置一个简单的参数。使 url 类似于:

http://www.mysite.com/MyPage.aspx?selected=1

然后在代码隐藏中查找该参数并选择服务器端按钮。

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        int selected;

        if (int.TryParse(Request.QueryString["selected"], out selected))
            RadioButtonList1.SelectedIndex = selected;
    }
}

No need to pass the ViewState around. What you need to do is put a simple parameter in the QueryString. Make the url something like:

http://www.mysite.com/MyPage.aspx?selected=1

Then look for that parameter in the codebehind and select the button server-side.

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        int selected;

        if (int.TryParse(Request.QueryString["selected"], out selected))
            RadioButtonList1.SelectedIndex = selected;
    }
}
做个ˇ局外人 2024-10-20 08:25:44

只需使用锚标记或超链接控件之一。我不确定你到底做了什么来获取所有回发数据,但听起来你不需要任何这些。

Just use the anchor tag or one of the hyperlink controls. I'm not sure exactly what you did to get all the postback data but it sounds like you don't need any of that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文