|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Adding client side code to RadioButtonList control item???I'm trying to add some javascript to my RadioButtonList control below but it
never seems to render in the browser? Is there an MS suggested work-around? I eventually want to hide/show sections of the page using DHTML with this javascript as buttons are clicked. while (reader.Read()) { ListItem item = new ListItem(reader["Title"].ToString()); if (reader["CheckedYn"].ToString() == "1") { item.Selected = true; } item.Attributes.Add("onclick", "alert('test');"); <--NEVER RENDERS??? radioButtonList.Items.Add(item); } 'The radiobutton list server controls renders an HTMLTable that has rows;
each has a radiobutton. There is no onclick event on the listitems for this control. If you want to do client-side programming you would have to do it by programming the onclick event of the RadioButtonList itself, e.g. //note: this javascript works only in IE rbList1.Attributes.Add("onclick", "if (window.event.srcElement.tagName=='INPUT') alert('you selected '+ window.event.srcElement.nextSibling.innerText);"); Show quoteHide quote "Dave" wrote: > I'm trying to add some javascript to my RadioButtonList control below but it > never seems to render in the browser? Is there an MS suggested work-around? > > I eventually want to hide/show sections of the page using DHTML with this > javascript as buttons are clicked. > > while (reader.Read()) > { > ListItem item = new ListItem(reader["Title"].ToString()); > if (reader["CheckedYn"].ToString() == "1") > { > item.Selected = true; > } > > item.Attributes.Add("onclick", "alert('test');"); <--NEVER RENDERS??? > radioButtonList.Items.Add(item); > }
GridView w/ ObjectDataSource w/ Business object layer
GridView, ObjectDataSOurce, and enum parameter for select Web UserControl (ascx) and UrlProperty attribute Cant get user-entered values in GridView Scrolling DG w/a Fixed Header Datalist formatting questions DataGrid1.DataSource = ds.Tables(2) Treeview SelectedNodeChanged event not firing GridView custom control and post back issues Strange addition of ViewState information with an inherited WebCon |
|||||||||||||||||||||||