
dotnetrockerzzz
Top achievements
Rank 2
dotnetrockerzzz
asked on 30 Sep 2011, 12:55 PM
- CASE SCENARIO :
- WHAT I WANT:
- Whenever we click on any item in the panel , new pageview gets created from code-behind , the ID of pageview is same as value of item getting clicked, the pageview dynamically loads an usercontrol (refer C# code)
- The Panel clicking also fires a javascript event in which if the pageview is already loaded it simply displays that pageview without any server-side event or postback occuring(refer javascript code)
ASPX CODE:
<
telerik:RadPanelBar
style
=
"margin-left:8px;"
ID
=
"RadPanelBar1"
Runat
=
"server"
Skin
=
"Office2007"
Width
=
"210px"
onitemclick
=
"RadPanelBar1_ItemClick"
OnClientItemClicked
=
"onitemclick"
>
<
Items
>
<
telerik:RadPanelItem
runat
=
"server"
Owner
=
"RadPanelBar1"
Text
=
"Speak & Listen.."
Expanded
=
"True"
>
<
Items
>
<
telerik:RadPanelItem
runat
=
"server"
Owner
=
""
Selected
=
"True"
Text
=
"Friends News Feed"
Value
=
"nfeed"
>
</
telerik:RadPanelItem
>
<
telerik:RadPanelItem
runat
=
"server"
Owner
=
""
Text
=
"Following Public Profiles"
Value
=
"try"
>
</
telerik:RadPanelItem
>
</
Items
>
</
telerik:RadPanelItem
>
</
telerik:RadPanelBar
>
<telerik:RadMultiPage ID="RadMultiPage1" runat="server" OnPageViewCreated="RadMultiPage1_PageViewCreated">
</telerik:RadMultiPage>
protected
void
RadMultiPage1_PageViewCreated(
object
sender, RadMultiPageEventArgs e)
{
}
protected
void
RadPanelBar1_ItemClick(
object
sender, RadPanelBarEventArgs e)
{
RadPageView pager =
new
RadPageView();
pager.ID = e.Item.Value.ToString();
Control userControl = Page.LoadControl(
"Newsfeed/"
+ e.Item.Value.ToString() +
".ascx"
);
userControl.ID = e.Item.Value.ToString() +
"usercontrol"
;
pager.Selected =
true
;
pager.Controls.Add(userControl);
RadMultiPage1.Controls.Add(pager);
}
JAVASCRIPT CODE
function
onitemclick(sender, args) {
var
multiPage = $find(
"<%=RadMultiPage1.ClientID%>"
);
var
item = args.get_item();
var
itemt = item.get_value();
if
(multiPage.get_pageViews().get_count() > 2) {
for
(
var
i = 0; i < multiPage.get_pageViews().get_count(); i++) {
if
(multiPage.get_pageViews().getPageView(i).get_id() == itemt) {
var
pageView = multiPage.findPageViewByID(itemit);
pageView.set_Selceted(
true
);
pageView.show();
item.set_postBack(
false
);
}
}
}
}
15 Answers, 1 is accepted
0

dotnetrockerzzz
Top achievements
Rank 2
answered on 01 Oct 2011, 02:48 PM
Teleik Admins can't crack this yet ?? why it is taking so much of time??
With best hopes and regards,
With best hopes and regards,
0
Hello Vaibhav,
Try to load the user control in the
Greetings,
Dimitar Terziev
the Telerik team
Try to load the user control in the
OnPageViewCreated
event handler function of the RadMultiPage as shown in this demo here.Greetings,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

dotnetrockerzzz
Top achievements
Rank 2
answered on 05 Oct 2011, 06:24 AM
Changed my .aspx.cs code to ..
but still not working .. if that's what u were trying to say Mr.Dimitar Terziev is their anything else that could work??
protected
void
RadMultiPage1_PageViewCreated(
object
sender, RadMultiPageEventArgs e)
{
Control userControl = Page.LoadControl(
"Newsfeed/"
+ e.PageView.ID.ToString() +
".ascx"
);
userControl.ID = e.PageView.ID.ToString() + "usercontrol";
e.PageView.Selected =
true
;
e.PageView.Controls.Add(userControl);
RadMultiPage1.Controls.Add(e.PageView);
}
protected
void
RadPanelBar1_ItemClick(
object
sender, RadPanelBarEventArgs e)
{
RadPageView pager =
new
RadPageView();
pager.ID = e.Item.Value.ToString();
}
0
Hello Vaibhav,
The reason for the experienced behavior is the fact that you should add the newly created pageview to the PageViews collection of the mutlipage in order the
First you are adding the pageview in the wrong moment , second you are not using the appropriate collection. Change your code as following:
Regards,
Dimitar Terziev
the Telerik team
The reason for the experienced behavior is the fact that you should add the newly created pageview to the PageViews collection of the mutlipage in order the
PageViewCreated
event to be fired. First you are adding the pageview in the wrong moment , second you are not using the appropriate collection. Change your code as following:
protected
void
RadMultiPage1_PageViewCreated(
object
sender, RadMultiPageEventArgs e)
{
Control userControl = Page.LoadControl(
"Newsfeed/"
+ e.PageView.ID.ToString() +
".ascx"
);
userControl.ID = e.PageView.ID.ToString() +
"usercontrol"
;
e.PageView.Selected =
true
;
e.PageView.Controls.Add(userControl);
}
protected
void
RadPanelBar1_ItemClick(
object
sender, RadPanelBarEventArgs e)
{
RadPageView pager =
new
RadPageView();
pager.ID = e.Item.Value.ToString();
RadMultiPage1.PageViews.Add(pager);
}
Regards,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

dotnetrockerzzz
Top achievements
Rank 2
answered on 09 Oct 2011, 07:19 PM
Respected Dimitar ,
Apparently the JavaScript code does not work as it is expected , i have changed my code-behind code as you asked but still i am unable to achieve what i was aiming for .
As given in the demo(mentioned in your above post) ,after the person clicks on the the tab second time or third time .....it loads the pageview which is already loaded in the page , i am trying to do same with the panel bar but as it does not have a property of 'PageviewID' some problem is occurring. Please go through my code and tell where i could be wrong... . The code is in <div runat="sever">//JavaScript code</div>
Apparently the JavaScript code does not work as it is expected , i have changed my code-behind code as you asked but still i am unable to achieve what i was aiming for .
<script type=
"text/javascript"
>
function
onitemclick(sender, args) {
var
multiPage = $find(
"<%=RadMultiPage1.ClientID%>"
);
var
item = args.get_item();
var
itemt = item.get_value();
if
(multiPage.get_pageViews().get_count() > 0) {
for
(
var
i = 0; i < multiPage.get_pageViews().get_count(); i++) {
if
(multiPage.get_pageViews().getPageView(i).get_id() == itemt) {
var
pageView = multiPage.findPageViewByID(itemit);
pageView.set_Selceted(
true
);
pageView.show();
item.set_postBack(
false
);
}
}
}
}
</script>
0

dotnetrockerzzz
Top achievements
Rank 2
answered on 11 Oct 2011, 03:57 PM
I am using Ajax Manager could that be a problem?
0
Hello Vaibhav,
Try to disable the Ajax and check whether the problem persists. In case the problem is related to the Ajax then provide the Ajax setting that you are using.
Kind regards,
Dimitar Terziev
the Telerik team
Try to disable the Ajax and check whether the problem persists. In case the problem is related to the Ajax then provide the Ajax setting that you are using.
Kind regards,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

dotnetrockerzzz
Top achievements
Rank 2
answered on 16 Oct 2011, 02:05 PM
I disabled ajax but it does not work any ideas why so ???
0

dotnetrockerzzz
Top achievements
Rank 2
answered on 23 Oct 2011, 10:22 AM
Telerik Adimns ill or what??? can't figure this out yet?? hlp needed ...
0
Hello Vaibhav,
I've prepared a sample page demonstrating how to achieve the desired functionality.
All the best,
Dimitar Terziev
the Telerik team
I've prepared a sample page demonstrating how to achieve the desired functionality.
All the best,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

dotnetrockerzzz
Top achievements
Rank 2
answered on 28 Oct 2011, 10:02 AM
Thank you , sir ..
that example worked well, thank you ...
the only problem which needs to be corrected is ..
needs to be changed to
Thanking Telerik team for showing late but good support ..
that example worked well, thank you ...
the only problem which needs to be corrected is ..
protected
void
RadMultiPage1_PageViewCreated(
object
sender, Telerik.Web.UI.RadMultiPageEventArgs e)
{
Control userControl = Page.LoadControl(
"UserControls/"
+ e.PageView.ID.ToString() +
".ascx"
);
userControl.ID = e.PageView.ID.ToString() +
"usercontrol"
;
e.PageView.Selected =
true
;
e.PageView.Controls.Add(userControl);
}
Page.LoadControl(
"UserControls/"
+ e.PageView.ID.ToString() +
".ascx"
);
needs to be changed to
Page.LoadControl(
e.PageView.ID.ToString() +
".ascx"
);
Thanking Telerik team for showing late but good support ..
0

dotnetrockerzzz
Top achievements
Rank 2
answered on 22 Dec 2011, 12:04 PM
Going through your solution I incurred a little problem : if i click on a button twice in the usercontrol it redirects me to another usercontrol!!?? why it is so ??
0

dotnetrockerzzz
Top achievements
Rank 2
answered on 25 Dec 2011, 12:20 PM
Somebody please help!!
0
Hi Vaibhav,
I've prepared a sample page trying to reproduce the experienced problem, but to no avail. You could find it attached.
Could you provide more information for your particular implementation? Do you handle the button click event and if so what is the custom logic that you are using in the event handler function?
All the best,
Dimitar Terziev
the Telerik team
I've prepared a sample page trying to reproduce the experienced problem, but to no avail. You could find it attached.
Could you provide more information for your particular implementation? Do you handle the button click event and if so what is the custom logic that you are using in the event handler function?
All the best,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

dotnetrockerzzz
Top achievements
Rank 2
answered on 20 Jan 2012, 10:01 AM
Well , I think so i have got the solution ..
the problem was their was a input having id as RadMultiPage1_ClientState with value="{"selectedIndex":0,"changeLog":[]}" now whenever i used to postback ...the first time the postback used to work fine ,but the textbox/input's value would change to null ,
and thus the RadMultiPage would not know which Pageview is seleceted ..
Hence, if u ajaxify the usercontrols they would work upto your expectations ...as the textbox value will not change
thanks for your help ...
Regards
the problem was their was a input having id as RadMultiPage1_ClientState with value="{"selectedIndex":0,"changeLog":[]}" now whenever i used to postback ...the first time the postback used to work fine ,but the textbox/input's value would change to null ,
and thus the RadMultiPage would not know which Pageview is seleceted ..
Hence, if u ajaxify the usercontrols they would work upto your expectations ...as the textbox value will not change
thanks for your help ...
Regards