Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

AppTheory specializes in solutions based on the DotNetNuke platform and has 2 employees on the DotNetNuke Core Team.
  Ads  
Active Modules -- Active Forums for DotNetNuke
 


  Sponsors  

Meet Our Sponsors

.: CounterSoft :.
telerik
ExactTarget email software solutions
Merak Mail Server
WebSecureStores -- ASP.NET & DotNetNuke Hosting Solutions
FCKeditor Project
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  ClientAPI Compo...  Rendering server cotrols with AJAX
Previous Previous
 
Next Next
New Post 12/9/2005 5:47 AM
User is offline Ulu Honolulu
4 posts
10th Ranked


Rendering server cotrols with AJAX 

Hi All

Sometimes you want to render a server control's HTML to a string. Here's how you do that (I took this code from http://www.codeproject.com/aspnet/DAtaGridExportToExcel.asp):

Function GetControlSource(ByVal ctrl As System.Web.UI.WebControls.WebControl) As String
Dim srcWriter As New IO.StringWriter, htmlWriter As _
      
New System.Web.UI.HtmlTextWriter(srcWriter)
ctrl.RenderControl(htmlWriter)
Return srcWriter.ToString
End Function

But then, often you'd like to render the updated HTML back to the client. Suppose you edit an article and want to change its author. You try to choose it from the list and then discover that you have to add a new author. Normally you'll have to go to a separate page and add the author there, than return back and choose the new author. A more natural way would be to add the author here and then have the author list refresh without page refreshing.

So, we can easily add an author using the ClientAPI. Bu how to render the dropdownlist with the newly added author? If you try the code above, you'll have an error because the control is not a part of a page. Here comes my hack. If you use Lutz Roeder's Reflector, you'll see that the exception comes from the Page's VerifyRenderingInServerform Method. Fortunately, it's overridable, so we can just add the following code to the CDefault class:

Public Overrides Sub VerifyRenderingInServerform(ByVal control As System.Web.UI.Control)

End Sub

Now you can use the code to send any control's source to the client. The client handler should substitute the control's source with the new one, and you can have everything refresh smoothly without postbacks.

Hope this helps

Ulu

 
Previous Previous
 
Next Next
  Forum  DotNetNuke® Pro...  ClientAPI Compo...  Rendering server cotrols with AJAX
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Windsor Management Group
Fund Accounting Software for K12 Education.
Infinitevisions.com
Convert Visitors to Customers
In order to bring value to your users, we must first understand them. VIVIDSITES will help you build a custom web application and interactive marketing tools that your users will thank you for. We marry high-end creative with head banging technology to entertain and convert visitors into paying customers. Call 314.514.0505 or visit us at http://www.vividsites.com to find out how.
- V I V I D S I T E S -
Gearworx Web Hosting
As a premier provider of Web Hosting, Private/White Label hosting, Server Colocation, Dedicated Server, and other Managed Services, Gearworx offers an array of services designed to more effectively manage strategies driving businesses on the Web. Headquartered in Fremont, California our state of the art tier one data centers and distributed managed services environment enables Gearworx to offer your business enterprise level solutions through simplified processes.
Gearworx Web Hosting

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP