Get Runtime Reference To Editor Object In Nested User Control (ascx).

Last post 07-11-2004, 12:34 AM by jeff330ci. 3 replies.
Sort Posts: Previous Next
  •  07-07-2004, 3:10 PM 1190

    Get Runtime Reference To Editor Object In Nested User Control (ascx).

    I have implemented a CuteEditor ("Editor") in a user control that appears within another user control which appears on an aspx page. Yes - two nested user controls within an aspx page. At runtime, the name of the Editor as rendered in the HTML in the browser is '_ctl1__ctl3_Editor1'
     
    Issue: On postback, I need to somehow get a reference to the Editor. The following line does not work when executed from the Page_Load event during a postback (FindControl always returns null):
    Control incomingEditor = FindControl("_ctl1__ctl3_Editor1");
     
    My temporary work-around is to loop through the Forms collection, looking for '_ctl1__ctl3_Editor1'. The value of this member of the Forms collection contains what I believe is the Text value of the Editor - however I cannot be sure because it may really be the (innerText or innerHTML value). In any case even if it is the Text value, I have no way to get the XHTML value which is a member of the runtime Editor object. And, as far as I know, the XHTML value is not available via the Forms collection. My work-around won't be acceptable for my production implementation.
     
    I'd really appreciate any suggestions on how to get a true reference to the Editor object when it resides in nested user controls as described above. FWIW, I'm using C#/code-behind
     
    Thanks!
  •  07-07-2004, 6:19 PM 1192 in reply to 1190

    Re: Get Runtime Reference To Editor Object In Nested User Control (ascx).

    jeff330ci,

     
    Have you checked Working with DataGrid Example? I hope that example can help you a bit.
     
    If not,  please create an example or send the URL to us.

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  07-07-2004, 6:19 PM 1193 in reply to 1190

    Re: Get Runtime Reference To Editor Object In Nested User Control (ascx).

    jeff330ci,

     
    Have you checked Working with DataGrid Example? I hope that example can help you a bit.
     
    If not,  please create an example or send the your page URL to us.

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  07-11-2004, 12:34 AM 1215 in reply to 1193

    Re: Get Runtime Reference To Editor Object In Nested User Control (ascx).

    For those interested in the followup on this...

     
    I decided to take a simpler approach. The "wall I ran into" was not simply that the CuteEditor was appearing within a nested user control, but that the user controls were being dynamically added to the ASPX page. They therefore simply do not exist on PostBack, so there is no control (i.e., CuteEditor) to which I can get an object reference. Put another way, the FindObject method has no container within which to search for the CuteEditor.
     
    Note that this has absolutely nothing to do with the CuteEditor.
     
    If I was not dynamically adding the user controls to the aspx page, then I'd be in business. So, if you are declaratively including user controls on an aspx page, then you could use FindControl() to get a reference to the CuteEditor that exists within the user control.
     
    Here's a link to a great article on FindControl for those interested: http://odetocode.com/Articles/116.aspx
View as RSS news feed in XML