[CLOSED] render dynamic control

  1. #1

    [CLOSED] render dynamic control

    I load information from a control and add to panel , in a precise moment, i need to load more information / more controls . The controls generated after the click of the button, doesn't appear on the screen , the UpdateContent not worked.

    How can I render these controls without reloading the page ?

      protected void Page_Load(object sender, EventArgs e)
        {
            this.hdnQtdOcorrencia.Value = Convert.ToInt32(this.hdnQtdOcorrencia.Value) == 0 ? 10 : this.hdnQtdOcorrencia.Value;
            this.carregarOcorrencias();
    
        }
     
    protected void carregarOcorrencias() { int tamanhoDt = Convert.ToInt32(this.hdnQtdOcorrencia.Value); ocorr.qtdOcorrencia = tamanhoDt; dt = ocorr.buscarOcorrencias(); if (tamanhoDt <= 10) { dtTake = dt.Rows.Cast<DataRow>().OrderByDescending(x => x["OC_ID"]).ToList(); } else { dtTake = dt.Rows.Cast<DataRow>().OrderByDescending(x => x["OC_ID"]).Skip(tamanhoDt - 10).ToList(); } foreach (var row in dtTake) { CONTROLS_ocorrenciasMural c = (CONTROLS_ocorrenciasMural)this.LoadControl("~/CONTROLS/ocorrenciasMural.ascx"); c.setValues(row); Ext.Net.Hyperlink nOcorrencia = (Ext.Net.Hyperlink)c.FindControl("hypVisualizar"); c.ID = "control" + nOcorrencia.Text; this.panelOcorrencias.ContentControls.Add(c); //this.panelOcorrencias.UpdateContent(); } }
     <ext:hidden runat="server" ID="hdnQtdOcorrencia"></ext:hidden>
     <ext:Panel ID="panelOcorrencias"  runat="server" Region="Center" Flex="5" OverflowY="Auto" Border="false" Frame="false" Layout="VBoxLayout">
                                <LayoutConfig>
                                    <ext:VBoxLayoutConfig Align="Center"></ext:VBoxLayoutConfig>
                                </LayoutConfig>
     </ext:Panel>
    <ext:Button runat="server" UI="Primary" Text="Mais OcorrĂȘncias" AutoLoadingState="true">                                  
             <Listeners>
                     <Click Handler="App.direct.onClickMaisOcorrencias(#{hdnQtdOcorrencia}.getValue());"></Click>
            </Listeners>
    </ext:Button>

    public void onClickMaisOcorrencias(int qtdOcorrencia) { this.hdnQtdOcorrencia.Value = qtdOcorrencia + 10; this.carregarOcorrencias(); }
    Last edited by Daniil; Sep 11, 2015 at 1:27 PM. Reason: [CLOSED]
  2. #2
    any ideas ?
  3. #3
    Hello everybody,

    Please try to add c.Render();. Also .ContentControls is better to replace with .Items.
    protected void carregarOcorrencias()
    {
        ...
    
        foreach (var row in dtTake)
        {
            ...
    
            this.panelOcorrencias.Items.Add(c);
            c.Render();
        }
    }
    If it doesn't work, please provide a full (but simplified) test case to reproduce the problem.
  4. #4
    Daniil, I can't Render the c variable because is a asp.net control.

    there anything I can use to convert this control to Ext element ?

    public partial class CONTROLS_ocorrenciasMural : System.Web.UI.UserControl
  5. #5
    I solve this way,.

         
    ctn.ContentControls.Add(c);
    ctn.Render(this.panelPaiOcorrencias, count, RenderMode.InsertTo, true);
    But all the elements with functionality doesn't work anymore, with this error: BADRESPONSE: Unexpected identifier

    Server Error in '/SOC' Application. The control with ID 'control10733_btnGravar10733' not found Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The control with ID 'control10733_btnGravar10733' not found Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [HttpException (0x80004005): The control with ID 'control10733_btnGravar10733' not found] Ext.Net.ResourceManager.RaisePostBackEvent(String eventArgument) +1823 System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +9672326 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34249
  6. #6
    Hello @miltonfoti!

    I'm really sorry, but it is clueless how to help you in this unless you can provide us a runnable and simplified example on how to reproduce your issue.

    If in doubt on how to come up with a simple runnable example, please refer to these posts:
    - Forum Guidelines For Posting New Topics
    - More information required

    Look at these recent forum threads for actual examples on how people are making their problems reproduceable by us:
    - TextArea Custom CSS
    - Grid CheckBox Selection
    - Destroying fields when RightButton is defined

    Hope this helps you providing us information that we can use to give you good advice on how to fix the issue. Also, happened to me more than once, while building the simpler standalone approach to reproduce an issue I found myself there was an error on my application and other times I could find myself what was wrong. Well, and sometimes I just could reproduce the issue in the simplified example and pasted it in my question, getting quick help.
    FabrĂ­cio Murta
    Developer & Support Expert
  7. #7
    Totally agree with Fabricio. A test case to reproduce a problem is the shortest way for a solution in 99% of cases. I'll just share my thoughts and guesses.

    First of all, sorry for my suggestion to call .Render() to a not an Ext.NET control. I somehow concluded that it is an Ext.NET control.

    Actually, I would try .UpdateContent() in your scenario as well as you did. Difficult to say why it didn't work for you, but I remember issues are possible with such kind of scenarios, i.e. rendering of non-ASP.NET controls dynamically during AJAX requests.

    Anyways, calling .Render() on an Ext.NET control is a good alternative and it should be called during AJAX request only (as well as .UpdateContent()). It must not be called during initial page load.

    Please try to replace:
    ctn.ContentControls.Add(c);
    ctn.Render(this.panelPaiOcorrencias, count, RenderMode.InsertTo, true);
    with
    ctn.ContentControls.Add(c);
    
    if (X.IsAjaxRequest)
    {
        ctn.Render(this.panelPaiOcorrencias, count, RenderMode.InsertTo, true);
    }

Similar Threads

  1. Render Dynamic Control in View
    By ehmdb in forum 3.x Help
    Replies: 1
    Last Post: Jun 17, 2015, 2:02 PM
  2. [CLOSED] User Control Render dynamic value assign issue in page load
    By shaileshsakaria in forum 2.x Premium Help
    Replies: 1
    Last Post: Apr 26, 2014, 6:19 PM
  3. Replies: 0
    Last Post: Aug 23, 2013, 12:16 PM
  4. Replies: 1
    Last Post: Apr 25, 2013, 7:02 AM
  5. Dynamic grid does not render in a dynamic panel
    By Wellington Caetano in forum 1.x Help
    Replies: 4
    Last Post: Apr 12, 2011, 10:19 PM

Tags for this Thread

Posting Permissions