+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Embedding Usercontrols

Embedding Usercontrols

7 posts, 0 answered
  1. Vijaianand
    Vijaianand avatar
    94 posts
    Registered:
    09 Jul 2012
    11 Oct 2010
    Link to this post
    I just completed desiging and developing lot of user controls with our line of business. Currently working to incorporate them into ver 3.6 sitefinity. Whenever I insert a user control to the page, it literaly executes the control and fails because the objects are not created yet. How to stop sitefinity from executing the usercontrols or loading them when its getting inserted to the page. Any way to do it?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Oct 2010
    Link to this post
    Hi VIJAIANAND,

    You can check whether you are in edit mode and not call your control logic, so the objects will not be used.

    if(!HttpContext.Current.Request.QueryString[ "cmspagemode"] == "edit")
      {
       //we are not in edit mode execute your logic here
      }

    Note that in page edit mode, the Page object is null and you may get null reference exception if you do not check for nulls.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Vijaianand
    Vijaianand avatar
    94 posts
    Registered:
    09 Jul 2012
    11 Oct 2010
    Link to this post
    Hey Ivan

    Thanks for quick response as usual. But I don't want to add any sitefinity type code in the user controls. User controls should work standalone when incorporated whether in Sitefninty or any other CMS or standalone app. I don't like to add any code. Is ther any web.config setting or anything which will disable to user control page load when inserting.

    Vijai
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Oct 2010
    Link to this post
    Hi VIJAIANAND,

    if you have added the controls in Sitefinity page and you edit this page some of the control events will be triggered - Page_Load, OnPreRender etc and this cannot be avoided.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Vijaianand
    Vijaianand avatar
    94 posts
    Registered:
    09 Jul 2012
    11 Oct 2010
    Link to this post
    Oh really! Thats not going to help much since we have lot of user control which checks for objects on pre_render. I think I would have to disable them first and add them and reenable the code to get it working.

    Anyway, let me ask you one more qustion. I have a server transfer in the user control which take url from resource file. I added the virtual aspx created in the sitefinity as the url in the resource file. I don't think its working. It keep saying the files not found. What is the work around or suggestion?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Oct 2010
    Link to this post
    Hi VIJAIANAND,

    You should better use cookie, session or QueryString. It is not possible to use Searver.Transfer or some cross methods, because all of them expect physical files, which actually can be created as external pages in Sitefinity. Sitefinity pages are not physical files and they are dynamically created.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Vijaianand
    Vijaianand avatar
    94 posts
    Registered:
    09 Jul 2012
    11 Oct 2010
    Link to this post
    Yeah, thats what I thought. BUt I just discovered response.redirect works and since its same session I didn't lose the session stuff as stuff. I might either use response.redirect or create them as external page which should help too.

    Thanks Ivan.
Register for webinar
7 posts, 0 answered