[CLOSED] Web Service Render ASCX

  1. #1

    [CLOSED] Web Service Render ASCX

    Hi,
    i'd like to generate an ascx in a webmethod.
    In fact, in the webmethod "renderTo",

    1 - I created the new Page()
    2 - I added the HtmlForm to the page
    3 - I added the Ext.Net.ResourceManager to the HtmlForm
    4 - then I tried to load rm.ascx, I did the databind and
    5 - I did the "page.RenderControl(wr)" (point where i encoutered the error)

    I correctly did all of these passages with the 1.0.0.15317 ext.net version

    but with the 1.0.4414.20616 and 1.0.4485.18804 versions I'm facing this problems

    what could I do to solve my problem?

    thank you


    RM.ASCX:

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="RM.ascx.vb" Inherits="GoogleExtMaps.RM" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <ext:Button runat="server" ID="bttn" Text="---"></ext:Button>
    RM.ASCX.VB:

    Public Class RM
        Inherits UserControl
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        End Sub
        Public Overrides Sub DataBind()
            bttn.Text = "TEST VALUE"
        End Sub
    End Class


    WEB SERVICE:
    <WebMethod(True)> _
        <System.Web.Script.Services.ScriptMethod(ResponseFormat:=System.Web.Script.Services.ResponseFormat.Json, UseHttpGet:=False)> _
        Function renderTo(Userid As String, Lingua As String) As ExtResult
            Dim res As New ExtResult
            Dim Controllo As New UserControl
            Try
                Controllo = Controllo.LoadControl("rm.ascx")
                Controllo.DataBind()
               
                Dim page As Page = New Page()
                Dim Sw As New System.IO.StringWriter
                Dim RMExtNet As New Ext.Net.ResourceManager
                Controllo.EnableViewState = False
                page.EnableViewState = False
                page.EnableEventValidation = False
                Dim form As New HtmlForm
                form.ID = "ExtNetFormContainer"
                form.Controls.Add(RMExtNet)
                form.Controls.Add(Controllo)
                page.Controls.Add(form)
    
                Dim wr As New System.Web.UI.HtmlTextWriter(Sw)
    
                page.RenderControl(wr) '<- ERROR ############################
            Catch ex As Exception
                res.Errore = "Errore: " & ex.Message
            End Try
            
            Return res
    
        End Function
    Last edited by Daniil; Apr 16, 2012 at 12:41 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please investigate how we render a user control in WebService in the following example.
    https://examples1.ext.net/#/Calendar...w/Remote_Data/

    We would suggest to use that way.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    Please investigate how we render a user control in WebService in the following example.
    https://examples1.ext.net/#/Calendar...w/Remote_Data/

    We would suggest to use that way.
    thank you Daniil for your reply, but what I want to do is trying to solve what I did in my code,
    because it is at the base of my project and without any solution I can't go away..
    As I told you before this post, with 1.0.0.15317 ext.net version I was able to use page.RenderControl(wr) but with the new version I can't.
    where is the difference between the old version and the new versions?

    thank you very much
  4. #4
    Hi,

    Just your approach is incorrect, you have to use XRender functionality (ToScript or Render methods of Ext.Net widget)
    If your code works in 1.0.xxx then it doesn't mean that it will work in other versions because you use doesn't recommended rendering

    Possible reasons why your code doesn't work:
    - Controls doesn't rendering own script if X.IsAjaxRequest==true (this rule is ignored if controls are rendered in ToScript/Render methods)
    - Need to use SelfRenderingPage for dynamic rednering instead Page

    So, please investigate the example which Daniil mentioned
  5. #5
    Quote Originally Posted by Vladimir View Post
    Hi,

    Just your approach is incorrect, you have to use XRender functionality (ToScript or Render methods of Ext.Net widget)
    If your code works in 1.0.xxx then it doesn't mean that it will work in other versions because you use doesn't recommended rendering

    Possible reasons why your code doesn't work:
    - Controls doesn't rendering own script if X.IsAjaxRequest==true (this rule is ignored if controls are rendered in ToScript/Render methods)
    - Need to use SelfRenderingPage for dynamic rednering instead Page

    So, please investigate the example which Daniil mentioned
    thank you Vlad,
    SelfRenderingPage helped me

Similar Threads

  1. call .ascx
    By corsaronero in forum 2.x Help
    Replies: 4
    Last Post: Mar 21, 2012, 2:35 PM
  2. [CLOSED] Toggle Render? Refresh Render?
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 08, 2011, 3:13 PM
  3. Problem in Partial Render of an ascx in MVC
    By aliassaf in forum 1.x Help
    Replies: 0
    Last Post: Nov 05, 2009, 5:22 AM
  4. ASCX and AjaxMethod
    By Maia in forum 1.x Help
    Replies: 2
    Last Post: Mar 11, 2009, 10:06 AM
  5. [CLOSED] Problem with ascx
    By flaviodamaia in forum 1.x Help
    Replies: 2
    Last Post: Nov 06, 2008, 12:38 PM

Tags for this Thread

Posting Permissions