I am using Telerik controls to build Sharepoint web parts. We built a
solution to our customer using a RadTabStrip and a RadMultiPage, but
they now want to see similar functionality using a dropdown list. I am
attempting to use the following method to meet the customer's needs:
When the page renders, I select a new option in the drop-down box. I see the first pop-up, and then following error: "'null' is null or not an object." The line number is the line corresponding to the call to $find().
What is the appropriate way to hook a combo box to a multi-page?
public override void CreateChildControls() |
{ |
RadMultiPage multiPage = new RadMultiPage(); |
multiPage.ID = "MasterMultiPage1"; |
RadPageView newView = new RadPageView(); |
newView.ID = "PageView1"; |
RadPageView newView2 = new RadPageView(); |
newView2.ID = "PageView2"; |
multiPage.PageViews.Add(newView); |
multiPage.PageViews.Add(newView2); |
LiteralControl view1 = new LiteralControl("Page 1"); |
LiteralControl view2 = new LiteralControl("Page 2"); |
newView.Controls.Add(view1); |
newView2.Controls.Add(view2); |
RadComboBox box = new RadComboBox(); |
RadComboBoxItem item1 = new RadComboBoxItem(); |
RadComboBoxItem item2 = new RadComboBoxItem(); |
this.Controls.Add(box); |
this.Controls.Add(multiPage); |
box.Enabled = true; |
box.Items.Add(item1); |
box.Items.Add(item2); |
item1.Text = "Page 1"; |
item2.Text = "Page 2"; |
item1.Value = newView.ClientID.Replace('$', '_'); |
item2.Value = newView2.ClientID.Replace('$', '_'); |
box.OnClientSelectedIndexChanging = "OnSelectChanging"; |
box.OnClientSelectedIndexChanged = "OnSelectChanged"; |
string javascript = |
@" |
function OnSelectChanging(item, args) |
{ |
var item = args.get_item(); |
var value = item.get_value(); |
alert('Hiding element with ID ' + value); |
//var multiPage = document.getElementById(value); |
//multiPage.style.visible='hidden'; |
var multiPage = $find('<%='+value+'.ClientID%>'); |
if(multiPage.get_selected() == true) |
{ |
multiPage.unselect(); |
multiPage.hide(); |
} |
} |
|
function OnSelectChanged(item, args) |
{ |
var item = args.get_item(); |
var value = item.get_value(); |
alert('Showing element with ID ' + value); |
//var multiPage = document.getElementById(value); |
//multiPage.style.visible='visible'; |
var multiPage = $find('<%='+value+'.ClientID%>'); |
if(multiPage.get_selected() == false) |
{ |
multiPage.select(); |
multiPage.show(); |
} |
} |
"; |
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MultiPageControl",javascript, true); |
} |
When the page renders, I select a new option in the drop-down box. I see the first pop-up, and then following error: "'null' is null or not an object." The line number is the line corresponding to the call to $find().
What is the appropriate way to hook a combo box to a multi-page?