Hi, guys I am here again.

How are you?

As always, I have a dificult problem.Now I have two radionlistbuttons and when I click in the first i need to put a value in a textbox and when i click in the order i need to put another value in the same textbox.

I need to detect when the radiobuttonlist is clicked?

Is it possible?

Thanls a lot guys?

Regards

It sure is. You can also do this client side but here is a server side demonstration:

Code Behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace daniweb.web
{
  public partial class _Default : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      if (IsPostBack && (Page.FindControl(Page.Request.Params["__EVENTTARGET"]) == Radiobuttonlist1))
      {
        if (Radiobuttonlist1.SelectedValue == "Item1")
        {
          TextBox1.Text = "The first value was selected";
        }
        else if (Radiobuttonlist1.SelectedValue == "Item2")
        {
          TextBox1.Text = "The second value was selected";
        }
      }
    }
  }
}

Page Markup:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="daniweb.web._Default" %>
<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
	    <asp:radiobuttonlist ID="Radiobuttonlist1" runat="server" AutoPostBack="True">
				<asp:ListItem>Item1</asp:ListItem>
				<asp:ListItem>Item2</asp:ListItem>
			</asp:radiobuttonlist>
    	<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>

You can use the client side javascripts to achieve this. You can use Onchanged attribute to trigger the javascript function and then setting up the textbox value to the desired one.

You can use GetElementById or GetElementByTag javascript functions to find the required check boxes and text boxes.

This article has been dead for over six months. Start a new discussion instead.