---
title: "Modify page_load method for radiobuttonlist"  
description: "Modify page_load method for radiobuttonlist"  
author: "marcel ethan"  
published: 2014-08-26  
updated: 2014-08-26  
canonical: https://www.mindstick.com/forum/2150/modify-page_load-method-for-radiobuttonlist  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# Modify page_load method for radiobuttonlist

I have a page with radio buttons and a [textarea](https://www.mindstick.com/forum/155821/how-we-will-generate-textarea-control-using-htmlhelper-in-razor-view) that populates data dynamically based on your [selection](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box). The radio buttons act as a list of [article](https://www.mindstick.com/articles/95867/are-you-looking-for-500-credit-score-mortgage-lenders-houston-continue-reading-this-article) titles and on selection you see the [content](https://www.mindstick.com/articles/13019/get-the-best-content-marketing-pricing-packages-for-your-brand) of the article.

Within my pageload [method](https://www.mindstick.com/forum/166/webservice-method), I want to allow users to be able to see a URL in their [browser](https://www.mindstick.com/blog/155254/which-is-the-best-internet-browser) that points to value they've. That way they can link to the article within another source.

Currently, the method I have allows me to link to the button selection if I manually type in the following example URLs:

http://localhost/test/Articles_test.aspx?selected=1

http://localhost/test/Articles_test.aspx?selected=2

I'd like to modify this so that the URL appears in the browser when a [radio button](https://www.mindstick.com/articles/12743/radio-button-in-android) selection is made. Plus, on [page load](https://www.mindstick.com/articles/12909/how-to-open-first-time-popup-on-page-load-in-website) defaults to the "0" index if no value [parameter](https://www.mindstick.com/blog/450/parameter-class-in-c-sharp) was specified.

```
protected void Page_Load(object sender, EventArgs e){       if (!IsPostBack)    {        int selected;        if (int.TryParse(Request.QueryString["selected"], out selected))            RadioButtonList1.SelectedIndex = selected;            RadioButtonList1.DataBind();            }}protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e){        string strRedirect;        strRedirect = "frm_Articles.aspx?selected=" + RadioButtonList1.SelectedIndex;        Response.Redirect(strRedirect);}
```

## Replies

### Reply by Sumit Kesarwani

Hi Marcel,\

Set your radiobutton list to post back on change. Then, in the handler, do a redirect to the appropriate URL:

```
protected void Page_Load(object sender, EventArgs e){       int selected;    if (int.TryParse(Request.QueryString["selected"], out selected))        RadioButtonList1.SelectedIndex = selected;        RadioButtonList1.DataBind();        }protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e){    string strRedirect;    strRedirect = "frm_Articles.aspx?selected=" + RadioButtonList1.SelectedIndex;    Response.Redirect(strRedirect);}
```


---

Original Source: https://www.mindstick.com/forum/2150/modify-page_load-method-for-radiobuttonlist

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
