Any idea on why this may be happening?
Also, when more than 1 RadAjaxPanels are on the same page, it seems that all the other update panels work fine on their 1st trigger, it's just the first request from any of them that seems to be a problem.
These are inside a formview in a user control, if that matters.
45 Answers, 1 is accepted
Although I'm not sure what might be causing the problem, we always recommend using a RadAjaxManager/Proxy in a WebUserControls scenario:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Ajax/Examples/Manager/UserControl/DefaultCS.aspx
Please, give it a go and let us know if that helps.
Sincerely yours,
Konstantin Petkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
So, adding the manager did not help.
Please, try a Manager outside the FormView as well as add the AJAX settings dynamically in this case (remove the AJAX Panel).
Feel free to write a support ticket to send a sample project. The attachments are not allowed in the forums.
Best wishes,
Konstantin Petkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I will submit a support ticket I suppose now. I am just wondering if you were speaking from experience in your suggestion or if you were just taking a guess that your suggestion *may* work?
Ajaxifying data sub controls might be a bit tricky in general due to the different naming containers. You may find this article interesting for example:
Ajaxify particlar templated GridView buttons
We will look into your project as soon as we can.
Greetings,
Konstantin Petkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I have the same problem with a RadAjaxPanel placed inside an ascx user control.
First time it does a full page postback, the it's working normally.
Are there any solutions to this issue?
Regards
Andrei Gosman
Andrei Gosman
The problem is related to the fact that the FormView in this case is not bound or bound too late for ajaxification. You can resolve this very easily if you access the FormView Controls collection in Page_Load. Here is an example:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Controls As ControlCollection = FormView1.Controls
End Sub
You can find modified version of your project attached.
That didn't however work in my example because I was using a formview inside of a user control. I can provide you with the sample project they gave me if you like. You can email me directly at donkitchen at gmail dot com and I'll send you the sample file.
thanks
I was able to get it working is kind of nasty but works...
The trick is calling the databind event and then adding ajax settings to the controls inside the detailsView before is rendered.
a few things first:
- My issue was that my user control was posting back the full page the first time it rendered.
- I was trying this with a DetailsView control insted of a FormView... my work around should work for you too...
- My trigger is a textbox (FirstNameTextBox) change that changes another textbox (AliasTextBox)
- Left all my code as it is (didn't remove ANYTHING, only added)
- Declared 2 text boxes on my code behind
TextBox txt1 = null, txt2 = null; - Added a PreRender event to my control
protected void Page_PreRender(object sender, EventArgs e) { if (!IsPostBack) { RadAjaxManager manager = RadAjaxManager.GetCurrent(Page); DetailsView1.DataBind(); if ((txt1 != null) && (txt2 != null)) { manager.AjaxSettings.AddAjaxSetting(txt1, txt2); } } } - Added a databound event to my detailsView Control
protected void DetailsView1_DataBound(object sender, EventArgs e) { Control x = ((DetailsView)sender).FindControl("FirstNameTextBox"); if (x != null) { txt1 = (TextBox)x; } x = ((DetailsView)sender).FindControl("AliasTextBox"); if (x != null) { txt2 = (TextBox)x; } } -
<!-- NON WORKING CASE --> |
<asp:Repeater ID="rptad" runat="server" DataSourceID="dsreview" > |
<ItemTemplate> |
<uc1:usercontrol containing the radajaxmanagerproxy> |
</ItemTemplate> |
</asp:Repeater> |
<asp:SqlDataSource ID="dsreview" runat="server"> |
... |
</asp:SqlDataSource> |
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
If Not Page.IsPostBack Then |
rptad.DataSource = dsreview |
rptad.DataBind() |
End If |
End Sub |
I have the same problem my scenario is with a FormView (with latest telerik asp.control 2008 pack)
<FormView mode="edit" DataSourceID="DsObject">
<EditTemplate>
<telerik:RadAjaxPanel>
<telerik:RadGrid>
..................................
</telerik:RadGrid>
......................................
......................................
</telerik:RadAjaxPanel>
</EditTemplate>
<FormView>
The first time that any children of the ajaxPanel perform a postback this is make as a full postback and subsequent postbacks by ajax, I confirm that is a Telerik bug because if you replace the RadAjaxPanel with an asp:UpdatePanel all work fine, the postbacks are made with ajax since the first time.
Please Telerik we need a solution, because out-of-the-box controls as an asp:UpdatePanel work fine in this scenario and yours not.
Regards,
Yuri
I also had this problem a while back. It turned out that I was changing the action on the form via Javascript. This caused the postback for the first Ajax call, but not for subsequent ones since the action wasn't being further changed.
One thing you can try is to ajaxify the whole control, by nesting it in an AjaxPanel, rather than the editForm. If this does not help, you can open a formal support ticket, and send us the problematic code, for additional testing and debugging.
Kind regards,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I have a master page with a single content page which loads usercontrols dynamically.
On a specific UC I have a radpanelbar, a radgrid, and other controls. Each of these is in a standard asp:Panel to get a fieldset/group frame. I load the panelbar manually and it seems to work fine on events. But the radgrid is databound to an objectdatasource. When the SelectedItemChanged event is fired, the grid is empty and there is no selected item or value. It's only after the event is fired and after the PreRender that the Select method is triggered on the data source. So now my thinking based on this thread is that I need to manually bind the grid in Page_Load so that the event has some data.
But I've been chasing at "what-if" ideas like this all week.
What if I wrap the grid in an AjaxPanel?
What if the asp:Panel is causing something funky?
What if I do or don't Ajaxify the asp:panel?
What if I move the AddAjaxSettings out of PreRender and move them somewhere else?
What if that script to avoid the x-microsoftajax header issue is causing Telerik Response.Writes to fail?
I just wish we had a better set of rules and better diagnostic tools. Working with a black box like this is an ongoing exercise in futility.
It's time to get away from the keyboard and re-think my approach to solving these problems...
I have a RadAjaxPanel. I load this panel manually by populating the Items collection.
I also have a RadAjaxGrid which is databound to an ObjectDataSource.
When the ItemClick event occurs on the panel, the required data is available in the event handler. The sequence of events that are fired are as follows:
Load
ItemClick
Select the ODS data for the grid
PreRender
When I click the grid, the SelectedIndexChanged is fired but the data is not available in the handler. The sequence of events here is as follows:
Load
SelectedIndexChanged
PreRender
Select method for ODS
Why the difference?
Following Dani's comments I added a mygrid.DataBind() to a handler executed from Page_Load. So the grid is bound and when the handler is invoked the data is there and everything with this now works fine.
Looking back at this I guess there are two things going on here: First there is the matter of when the handler fires, though that's not related to the data being available for the event. Second there's the matter of making sure data is available for the event. Why do I need to rebind? Why isn't it available from ViewState?
I really hate to play guessing games. Am I missing some fundamental rule of the ASP.NET page life cycle, or is there a bug somewhere?
Thanks to anyone who's reading, and I hope this helps anyone looking for a solution.
Hello Telerik team,
has a solution for this problem been found? I tried all suggestions in this threat, but it doesn't help me. The first postback is still a full postback.
Thanks,
Jaap
If you still experience issues as discussed in this thread, I suggest you isolate a working sample and send it enclosed to a regular support ticket. We will examine your test cases and will get back to you with our findings.
Kind regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I too have kind of given up on this and just learned to live with it for now.
Unfortunately I am not able to reproduce the abnormality following the directions from your posts. I requested a sample application because I suspect that there might be something specific in your configurations which causes the postback to happen. I will be expecting your working examples in order to provide as much to-the-point answer/solution as possible.
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
<telerik:RadScriptManager ID="ScriptManager" runat="server" /> |
<telerik:RadAjaxManager ID="AjaxManager" runat="server" /> |
<asp:FormView ID="Document" runat="server" DataSourceID="DocumentDataSource" |
DefaultMode="Edit" OnItemUpdating="Document_Updating"> |
<EditItemTemplate> |
<h2> |
Document Name: |
<%# Eval("Name") %></h2> |
<div> |
<asp:Label runat="server" AssociatedControlID="DocumentDate" Text="Document Date:" /> |
<telerik:RadDateInput ID="DocumentDate" runat="server" SelectedDate='<%# Bind("DocumentDate") %>' /> |
</div> |
<asp:Repeater ID="Sections" runat="server" DataSource='<%# Bind("Categories") %>' |
OnDataBinding="Sections_DataBinding"> |
<ItemTemplate> |
<asp:Panel ID="AjaxPanel" runat="server" OnPreRender="AjaxPanel_PreRender"> |
<contenttemplate> |
<asp:HiddenField runat="server" ID="Name" Value='<%# Eval("Name") %>' /> |
<h3> |
Section Name: |
<%# Eval("Name") %> |
</h3> |
<asp:LinkButton ID="Edit" runat="server" OnClick="Edit_Click" Text="Edit" /> |
<asp:LinkButton ID="Done" runat="server" Text="Done" Visible="false" OnClick="Done_Click" /> |
<telerik:RadListView ID="Items" runat="server" AllowMultiItemEdit="true" DataKeyNames="Name" |
OnNeedDataSource="Items_NeedDataSource"> |
<LayoutTemplate> |
<div> |
<asp:PlaceHolder ID="itemPlaceholder" runat="server" /> |
</div> |
</LayoutTemplate> |
<EditItemTemplate> |
<div> |
<asp:TextBox ID="Name" runat="server" Text='<%# Bind("Name") %>' /> |
</div> |
</EditItemTemplate> |
<ItemTemplate> |
<div> |
<asp:Literal ID="Name" runat="server" Text='<%# Eval("Name") %>' /> |
</div> |
</ItemTemplate> |
</telerik:RadListView> |
</contenttemplate> |
</asp:Panel> |
</ItemTemplate> |
</asp:Repeater> |
<asp:Button ID="Save" runat="server" CommandName="Update" Text="Save" OnClick="Save_Click" /> |
<asp:Button ID="Cancel" runat="server" CausesValidation="false" CommandName="Cancel" |
Text="Cancel" /> |
</EditItemTemplate> |
</asp:FormView> |
<asp:ObjectDataSource ID="DocumentDataSource" runat="server" DataObjectTypeName="Foo.Document" |
TypeName="Foo.DataSource" SelectMethod="RetrieveDocument" UpdateMethod="UpdateDocument" /> |
In the code behind:
protected void Document_Updating(object sender, FormViewUpdateEventArgs e) |
{ |
e.NewValues["Categories"] = ViewState["Sections_Data"]; |
} |
protected void Save_Click(object sender, EventArgs e) |
{ |
var save = (Control)sender; |
var sections = (Repeater)save.Parent.FindControl("Sections"); |
foreach(RepeaterItem repeaterItem in sections.Items) |
{ |
var done = (Control)repeaterItem.Controls[0].FindControl("Done"); |
if (done.Visible) |
{ |
Done_Click(done, EventArgs.Empty); |
} |
} |
} |
protected void Sections_DataBinding(object sender, EventArgs e) |
{ |
var sections = (Repeater)sender; |
ViewState["Sections_Data"] = sections.DataSource; |
} |
protected void AjaxPanel_PreRender(object sender, EventArgs e) |
{ |
RadAjaxManager.GetCurrent(this).AjaxSettings.AddAjaxSetting((Control)sender, (Control)sender); |
} |
protected void Items_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e) |
{ |
var items = (DataBoundControl)sender; |
var container = (IDataItemContainer)items.Parent.Parent; |
if (container.DataItem != null) |
{ |
items.DataSource = ((Category)container.DataItem).Items; |
} |
else |
{ |
var name = (HiddenField)items.Parent.FindControl("Name"); |
var dataSource = (List<Category>)ViewState["Sections_Data"]; |
items.DataSource = dataSource.Find(category => category.Name == name.Value).Items; |
} |
} |
protected void Edit_Click(object sender, EventArgs e) |
{ |
var edit = (Control)sender; |
var items = (RadListView)edit.Parent.FindControl("Items"); |
foreach (RadListViewDataItem item in items.Items) |
{ |
items.EditIndexes.Add(item.DisplayIndex); |
} |
items.Rebind(); |
var done = (Control)edit.Parent.FindControl("Done"); |
done.Visible = true; |
edit.Visible = false; |
} |
protected void Done_Click(object sender, EventArgs e) |
{ |
var done = (Control)sender; |
var items = (RadListView)done.Parent.FindControl("Items"); |
var name = (HiddenField)done.Parent.FindControl("Name"); |
var dataSource = (List<Category>)ViewState["Sections_Data"]; |
items.DataSource = dataSource.Find(category => category.Name == name.Value).Items; |
for (int i = 0; i < items.EditItems.Count; i++) |
{ |
((RadListViewDataItem)items.EditItems[i]).UpdateValues(((IList<DocumentItem>)items.DataSource)[i]); |
} |
items.ClearEditItems(); |
items.Rebind(); |
var edit = (Control)done.Parent.FindControl("Edit"); |
edit.Visible = true; |
done.Visible = false; |
} |
We are glad that you found a solution and shared it with the rest of the Telerik community members. As a token of gratitude I updated your Telerik points.
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Looking in your code, i still don't how you solved the problem of the first-time-postback. Can you help me out here?
Regards,
Jaap
If you replace the <asp:Panel /> with an UpdatePanel the first postback works properly. However if you use a RadAjaxPanel it does not. The key part of the solution was to use <asp:Panel /> inside the repeater and AJAXify it during PreRender. Rosen from Telerik support identiifed that the repeater item binding happens in a order that requires it to be like this: Here is what Rosen had to say in my support ticket:
- I suspect that the behavior you are experiencing is due to how the repeater items are added to the Page's controls collection. As you may know RadAjax does insert UpdatePanels on a fly however in order this to work controls should be present in the page's controls collection. It seems that at the stage when repeater items are created RadAjaxPanel is not added to the page yet
User Control source:
<telerik:RadAjaxLoadingPanel ID="ralpLoadingPanel" runat="server" Skin="Default" /> |
<telerik:RadGrid ID="rdUserAccounts" runat="server" AllowPaging="True" |
AllowSorting="True" EnableViewState="True" GridLines="None" PageSize="10" |
Skin="Office2007" Width="100%" OnNeedDataSource="rdUserAccounts_NeedDataSource" |
OnPreRender="rdUserAccounts_PreRender" > |
</telerik:RadGrid> |
<telerik:RadAjaxManagerProxy ID="rampAjaxManagerProxy" runat="server"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="rdUserAccounts"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl LoadingPanelID="ralpLoadingPanel" ControlID="rdUserAccounts" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManagerProxy> |
Code-behind source:
protected void rdUserAccounts_PreRender(object sender, EventArgs e) |
{ |
RadAjaxManager ram = RadAjaxManager.GetCurrent(this.Page); |
ram.AjaxSettings.AddAjaxSetting((Control)sender, (Control)sender); |
} |
Nothing else in my code changed. When I first started, my page would always do a full postback on the first AJAX call. After making these changes, the first AJAX call no longer forces a full postback.
Hope that helps.
Eric Skaggs
I also place two lines of code in the Load event of the page, one when postback is False and another when it is true. That line of code calls a js file that keeps track of the user time while is logged in.
Problem:
when the user uses the control inside the Radajax panel no page postback is being fired, where can I place my server code to capture usage of the controls inside the RadAjax panel in order to call the JS file and keep the user logged in?
It have nothing to do with DataBind();
I work with RadTreeView on a search popup, I remove for the test the treeview, and its DataBind() since in the page load it didn't help whatsoever.
I am still looking for help in this regard..
I have posted a thread few days ago, but no responses yet...
Best Regards,
Isaac
I appriciate your feedback related to the RadAjaxPanel doing postback first time.I have also faced the same issue related to this even ,may be found the solution within this thread itself but i am facing a issue which is restricting me to have a radajxpael or proxy inside usercontrol.Below is the issue:-
On my page, i have usercontrol(PurchaseFor.ascx) inside which i have again one usercontrol(SelectUser.ascx) .i have PurchaseFor.ascx inside page Purchases.aspx .Inside usercontrol (PurchaseFor.ascx) i have two asp radiobuttons (i.e first is for "Purchase for me" and second is for "Purchase for someonelse") both have autopostback property true. on click of "purchase for someonelse" radio button my another usercontrol gets visible i.e (SelectUser.ascx) and on click of first radiobutton it gets hidden.I want that on this radiobutton click it should do a asyc postback rather than full postback so i have taken RadAjaxManager proxy on my usercontrol (SelectUser.ascx) as follows:-
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy3" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="pnl1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="pnl1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
<asp:Panel ID="pnl1" runat="server" OnPreRender="pnl1_PreRender">
<table>
<tr>
<td>
<asp:RadioButton ID="rbMe" runat="server" Text="This purchase is for <strong>me</strong>."
AutoPostBack="true" GroupName="rb1" OnCheckedChanged="rb_Checked" />
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<asp:RadioButton ID="rbSomeoneElse" runat="server" Text="This purchase is for <strong>someone else</strong>."
CausesValidation="false" AutoPostBack="true" GroupName="rb1" OnCheckedChanged="rb_Checked" />
<asp:LinkButton ID="cmdChange" runat="server" Text="Change" OnClick="cmdChange_Click"
CssClass="colorTextLink" Visible="false" />
</td>
<td align="left">
<div style="height: 20px; position: relative" id="divtest" runat="server">
<uc2:SelectUser ID="selUser" runat="server" EnabledAddNew="false" Type="Users"
Width="290px" Required="true" OnPreRender="selUser_OnPreRender" />
</div>
</td>
</tr>
</table>
<asp:LinkButton ID="lnk" runat="server" OnClick="lnk_Click"></asp:LinkButton>
<asp:HiddenField ID="hdn" runat="server" />
</asp:Panel>
When i am putting the panel "pnl1" inside RadAjaxPanel its working fine i mean its updation the usercontrol "SelectUser" on click of radio button but its causing a postback first time issue later i trie with using RadAjaxManagerProxy when i had used proxy its throwing an exception please refer to the attach screen shot as (Error1.gif) .It gives an javascript error that .
"EditModeStyleCtl001_ContentPlaceHolder1_ctl01_selUser_mxl.." is undefined"
In my SelectUser.ascx i have one RadTextBox and div as well as we have uead a RadXmlHttpPanel which uses a webservice to bind RadGrid inside div.and when we start typing on textbox it populated grid with the results matching with the text enterd .I aslo tried to update RadXmlHttpPanel in proxy but stll no success.Please help us on this issue.
Thanks telerik team.
Can you specify how the PurchaseFor.ascx user control is added to the page, is it declaratively defined or dynamically loaded?
Additionally, I suggest that you do not put IScriptControls, as the RadGrid in RadXmlHttpPanel. You would better wrap the grid in RadAjaxPanel or ajaxify it with the RadAjaxManager available on the page.
Also, under which version of the .NET Framework is the project built?
Best wishes,
Iana Tsolova
the Telerik team
Thanks for the response.The PurchaseFor.ascx is dynamically loading.As inferenced by you i have not used grid i tried with div and not done any binding with grid simply used for loop and displayed recods in div itself but still i am facing the same issue.
As well as project built under version 4.0.30319 RTMRel of .Net Framework. And one more thing i cannot include div inside RadAjaxPanel as well dont want to ajaxify it with the RadAjaxManager available on the page. This user control has been used by other pages as well where i need a full postback .
Please recommend us how to proceed with this.
Thanks
What if you try o add the ajax settings for pnl1 dynamically, instead of using RadAjaxManagerProxy. For this purpose, you can comment out the proxy and in the SelectUser.ascx Page_Load server-side event handler add the below code:
protected
void
Page_Load(
object
sender, EventArgs e)
{
RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
manager.AjaxSettings.AddAjaxSetting(pnl1, pnl1);
}
If the issue persists, I would suggest that you open a formal support ticket and sends us a sample illustrating your exact scenario, or mimic it, and the issue.
Greetings,
Iana Tsolova
the Telerik team
I noticed this thread is almost 3 years old. Has a solution been found or an explanation offered? I just discovered the same issue but am using user controls/ajax proxies with RadComboBoxes/RadToolTips. Putting together a sample seems too tedious given the number of previous posts to this issue. I find myself falling into what TonyG's post above describes.
Can someone offer a general explanation to this issue? The fixes above seem only to apply to FormViews, DataGrids, etc.
Thanks,
Matt
Our scenario:
- a page based on a master page
- a user control called by the page dynamically.
The user controls contains RadGrids, RadEditor, etc.
If you take the code (of the master page, page and user control) and put it in a single page (as test) all works fine.
That means the problem is due to the order of Ajaxifying in a page + user control.
In short, what we ended up doing is:
In the user control's code behind we added the following in the Page_Load:
If Page.IsPostBack = False Then
If Session("1st") IsNot Nothing Then
Session.Remove("1st")
Else
Session.Add("1st", "first")
Response.Redirect(Request.Url.OriginalString)
End If
End If
This reloads the page on first load.
It's not very elegant, but it sure saves time.
Hi
After a coupe of hours searching for a solution - found this thread.
So the fastest solution is to replace:
this:
<
telerik:RadAjaxPanel
/>
with:
<
asp:UpdatePanel
runat
=
"server"
>
<
ContentTemplate
>
<%-- your controls here --%>
</
ContentTemplate
>
</
asp:UpdatePanel
>
The version of the library currently used is: Telerik.Web.UI 2015.3.930.40
Can someone confirm this bug is fixed in new version 2016.1 ?
Note that the posts in this thread are rather old and I can not be completely sure based on the provided information if the issue you are currently facing is a bug and of it workaround for other than using asp update panel exists. Can I kindly ask you to open a separate thread and provided detailed explanation for the issue you are currently facing? Thus we will be able to revise it locally and advise you further.
Regards,
Maria Ilieva
Telerik by Progress
Thanks for reply, I will check for this bug in the new versions and if it appears, I will open an issue.
Test your applictaion with the latest version of the controls and let us know how it goes.
Regards,
Maria Ilieva
Telerik by Progress
Hi,
I can confirm the bug in the current thread doesn't appears in the new versions;