This is a migrated thread and some comments may be shown as answers.

how to call a non-ajaxified rad window from a user control

4 Answers 54 Views
Window
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 02 Aug 2011, 05:54 PM
OK not sure if my title was too descriptive or not, but I am rather new to Talerik so this could just be a basic question. We are using a rad window for all our messages back to a user (process succesful, or failed, and etc.) some of our recent changes added user controls to a parent page and those need to now call the rad window that is on the aspx page of the parent page and pass the message to the user. How do we do this?

Here is current code on the parent page code behind when opening the window:
if (isSuccess)
{
message = "blah blah blah was successful, now do blah blah blah";
MessageRadWindow.NavigateUrl = "MessageAlert.aspx?message=" + encrypt.encrypt(message);
MessageRadWindow.Visible = true;
MessageRadWindow.VisibleOnPageLoad = true;
}

Now, that works well for what the message window is needed to do, however I am unsure how to call that same MessageRadWindow from the user control that is now embeded in that same page via a page.loadcontol method. I have attemtped different .GetControl methods and a couple things I found on the forums here and can neve get it to compile because it isn't finding the parent page controls for some reason. I am getting things like:
Error 281 The name 'RadAjaxManager1' does not exist in the currentcontext C:\_tfs\xxxx\xxxx\xxxx\Schedulexxxx.ascx.cs 81 14 xxxx_admin

What am I missing? Does the usercontrol need it's own ajax manager, and if so how do I get it there because I get errors stating cannot have more than on ajax manager on a page when I attempted to add one tot he user control?

4 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 02 Aug 2011, 06:05 PM
I made a typing mistake above, instead of getcontrol methods I meant to say, I attempted different

Page.FindControl 

calls as well as  .GetCurrent(this.Page) and had no luck. not GetControl...

0
Marin Bratanov
Telerik team
answered on 03 Aug 2011, 02:25 PM
Hello John,

If your RadWindows are all declared on the main page (the aspx) you can easily access them via JavaScript functions that are defined there as well. As to the way to open them - I would recommend injecting a JavaScript function from the code-behind instead of setting the VisibleOnPageLoad property to true, as this last approach usually results in the RadWindow showin up after each postback, which is rarely the desired behavior. If the use of the code-behind is not compulsory due to some business logic I would even recommend using the OnClientClick event of the desired buttons to save a round-trip to the server and thus improve performance.

For your convenience I prepared and attached a simple page that opens a RadWindow declared on the main page when a button in a user control is clicked.

I hope that my sample and the information above will help you achieve the desired functionality.


Best wishes,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
John
Top achievements
Rank 1
answered on 03 Aug 2011, 04:13 PM
Marin,

Thanks for the feedback, and yes I have noticed that all our pages that implement this radwindows for messaging require a postback and I also agree that this isn't the best solution, but since we go into a code freeze in 2 days for this months release I cannot go through and change all the other pages, and would want consistant behavior. That being said I created a hack of a workaround that will work for the time being then it can be enhanced for next months code release, yes we do monthly releases. Since this was a success/failure message after a database insert, there was no real button click to raise the alert action. So instead I just saved the message I was going to pass to radwindow to session then on the page we redirect to after the insert, on that page's page_init I check the session variable and if it is there and populated I set the VisibleOnPageLoad to true with the path and message just as we do already with all the other pages that do not have user controls and give the message on postback. then just after setting it I clear the session variable so it does not trigger on every postback. This works but like I said it is a bit of a hack and I would want to make it right after this release so I wil be reading up on that link you sent.

Thanks again,
John P.
0
Marin Bratanov
Telerik team
answered on 03 Aug 2011, 05:41 PM
Hello John,

I am glad that you have found a solution that works for the time being. I hope that the options I suggested earlier will be of help in your further development.

Since you are actually showing notifications to your users I would suggest that you examine our new control - RadNotification, as this is its exactly intended purpose. It provides a server-side Show() method which, I believe, will fit your needs nicely. You can examine its functionality in the following demos:
http://demos.telerik.com/aspnet-ajax/notification/examples/show/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/notification/examples/callback/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/notification/examples/settingcontent/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/notification/examples/configurator/defaultcs.aspx


Greetings,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Window
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or