Posted 24 Oct 2013
Link to this post
Sorry, apparently I am not able to post on this thread, sorry if I duplicate.
Hello Dimo, sorry but I have to come back to this issue.
The contentUrls[] to load seems not exactly what I need.
What I need to reproduce with kendo components is the following:
a panelbar with ul-li elements, but with the possibility to have a button or image on the li element - main item bar -, so that when I click this button a custom event handler is triggered, and a general functionality for the whole main item is provided.
The button is a Windows button on which in prionciple I have no control, it is created server-side that has attached a Onclick handler with a particular functionality.
In the bundle I enclose you can see a snapshot of what I mean. In the same bundle I enclose the aspx page and the code behind.
I think that the main issue is the link between client code and code-behind.
Let me try to summarize:
I am trying to build the whole control in the code-behind, I have a menu with main items - li elements - and subitems, ul elements.
I create a button as
Button testButton = new System.Web.UI.WebControls.Button();
testButton.ID = "btnTest";
testButton.Text = "OK";
testButton.Attributes.Add("style", "background-color: orange");
testButton.Click += new System.EventHandler(testButton_Click);
and I add it to the ul item
HtmlGenericControl ulbtn = new HtmlGenericControl("ul");
ulbtn.Controls.Add(testButton);
then I add this to the li item as
HtmlGenericControl libtn = new HtmlGenericControl("li");
libtn.InnerHtml = "Test btn";
libtn.Attributes.Add("id", "liBtn");
libtn.Controls.Add(ulbtn);
In the aspx page I have a placeholder as
<asp:PlaceHolder ID="PanelGeneric" runat="server"/>
in the code behind, in the Page_Load event the panelbar is added as
PanelKendo = new HtmlGenericControl("ul");
// Set the properties of the new HtmlGenericControl control.
PanelKendo.ID = "panelKendo";
PanelKendo.Controls.Add(libtn);
I run a script to initialize PanelNedo as a kendo panelbar with RegisterStartupScript
string kpanelinit = @"
<script type=\""text/javascript\""> $(document).ready(function () {
var initPanel = function () {
$(""#panelKendo"").kendoPanelBar({
});
};
initPanel();
});</script>
";
If I click the ul element with the button, the click event is fired and handled by the handler in the code behind, as obvious a postback occurs.
So far so good.
Now I try to position the same button on a main item bar, the li element, simply as
libtn.Controls.Add(testButton);
Just the Select/Expand/Collapse/Activate are fired, and not the server-side button click event.
I figured out how fire a further event clicking on the li element, I can add an attribute to the Control added to li as
testButton.Attributes.Add("onclick", "javascript:showDetails);");
but it is a client-side function, I need to call a server-side function.
PLEASE SUGGEST ME A WAY TO DO THIS.
Sorry for the length, I tried to explain my issue.
I will be grateful for your help, I'm stuck on this.
Best regards
Marco