Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
202 views
Welcome To Ask or Share your Answers For Others

1 Answer

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;
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...