Hi,

im making a application and am stuck :)

the page has 3 radio buttons, if the user has selected one i want the page to go to page2.aspx

if the user hasnt selected one i want an error message to be displayed (lblErr) and no navigation to happen.

im very confused ive been reading about altering the aspx code, postbacks, responce.redirect and loads of other things - but just cant seem to peice a solution together any help would be appriciated :)

protected void Button1_Click(object sender, EventArgs e)
    {
       
        if (radio1.SelectedValue == "Image Slot 1")
        {
            location = 1;
            Session["location"] = location;
            // go to page2
        }
        else if (radio1.SelectedValue == "Image Slot 2")
        {
            location = 2;
            Session["location"] = location;
            //go to page 2
        }
        else if (radio1.SelectedValue == "Image Slot 3")
        {
            location = 3;
            Session["location"] = location;
            //go to page 2
        }
        else
        {
            // dont go anywhere and display error message            
            lblErr.Visible = true;                       
           
        }

and here is the aspx

<asp:radiobuttonlist id="radio1" runat="server">
        <asp:listitem id="location1" runat="server" value="Image Slot 1" />
        <asp:listitem id="location2" runat="server" value="Image Slot 2" />
        <asp:listitem id="location3" runat="server" value="Image Slot 3" />
      </asp:radiobuttonlist>

any help (or if im asking for too much - any tips on what i have to research to do it!) would be most appreciated :)

Thanks

Never mind i sorted it out :)

if anyone needs to know under each if statmente i have put

Response.Redirect("page2.aspx");

nice :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.