You might be accidentally calling the click before the url is actually set.
nikkiH
Junior Poster in Training
79 posts since Dec 2006
Reputation Points: 13
Solved Threads: 4
Yes, and for me, it does.
You're inheriting code. Did you mean to do that?
Inherits="PassParameters._Default" %>
You had a couple other errors in there I fixed without thinking about it, too.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<hr />
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Value="http://www.daniweb.com/techtalkforums/post314320.html">Daniweb</asp:ListItem>
<asp:ListItem Value="~/test.aspx">Uke</asp:ListItem>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>
nikkiH
Junior Poster in Training
79 posts since Dec 2006
Reputation Points: 13
Solved Threads: 4
Here's what I had.
Note that posting to the daniweb address actually causes an error due to them not accepting POST from outside their domain. However, this still indicates success at postbackurl.
Also, I choose an option before clicking that button.
This is .NET 2.0, which I assume is what you're using, because IIRC 1.1 doesn't support this sort of thing.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<hr />
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Value="http://www.daniweb.com/techtalkforums/post314320.html">Daniweb</asp:ListItem>
<asp:ListItem Value="~/test.aspx">Uke</asp:ListItem>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
// Set the destination.
Button1.PostBackUrl = RadioButtonList1.SelectedValue;
//This should send me to a different page right?
Button1_Click((object)Button1, e);
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
nikkiH
Junior Poster in Training
79 posts since Dec 2006
Reputation Points: 13
Solved Threads: 4
Ah, I see.
Hang on a few, let me trace it.
nikkiH
Junior Poster in Training
79 posts since Dec 2006
Reputation Points: 13
Solved Threads: 4
Okay, no, that won't work like that.
Behind the scenes, all post back url does is change the onclick on the button CLIENT SIDE.
So changing it then trying to call onclick, before the code is written to the browser, won't work.
Here is view source from the browser.
onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("Button1", "", false, "", " http://www.daniweb.com/techtalkforums/post314320.html" , false, false))" id="Button1" />
So, to solve your problem, you can still use transfer, or you can register client side script block to auto-call the button click event when the page loads.
Transfer is, in my opinion, the better option.
nikkiH
Junior Poster in Training
79 posts since Dec 2006
Reputation Points: 13
Solved Threads: 4