I wish to add Query string to current url of site when i click on button. I dont know how its done in SharePoint but know how to do in asp.net like below
string url = HttpContext.Current.Request.Url.AbsoluteUri;
var uriBuilder = new UriBuilder(url);
var query = HttpUtility.ParseQueryString(uriBuilder.Query);
query["Myparam"] = "test";
uriBuilder.Query = query.ToString();
url = uriBuilder.ToString();
Response.Redirect(url);
Update1
I tried below code in selectedIndexChange event of option button
protected void RadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(GetType(), "test",
"<script type=\"text/javascript\">AddQueryString('" +
RadioButtonList.SelectedValue).ToString() + "');</script>)");
}
Then in .ascx file i wrote below
<script type="text/javascript">
function AddQueryString(querystring) {
SP.SOD.executeFunc("SP.js", "SP.ClientContext", function()
{
SP.Utilities.UrlBuilder.replaceOrAddQueryString(window.location.href, "param1", querystring);
});
}</script>
But its not updating url With Query string. Why? I have checked that there are no errors in console and code executes sucessfully.