More in this section

Forums / Developing with Sitefinity / Modules and User Controls

Modules and User Controls

9 posts, 2 answered
  1. Daniel
    Daniel avatar
    62 posts
    Registered:
    20 Apr 2009
    10 Aug 2009
    Link to this post
    Hi Support

    I have recently integrated a couple of custom modules with my sitefinity development and I have a slight issue!

    In the controlpanel user control I have a Gridview and in the toolbox control I have a few links one of which is a search item.

    Basically when you search for a reference number I want the gridview to display that record.

    I have the correct sql to do this however I require the ID of the usercontrol i.e. when you reference it in normal .NET you give it an ID and a runat server tag. Unfortunatly I do not know what the ID is as it is added from the class file (I think).

    If you could give me the naming convention that the id might use that would be great if not is there any other way to accomplish this?

    Thanks

    Daniel
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    11 Aug 2009
    Link to this post
    which control are you attempting to grab, the one on the controlpanel (your grid) or the one on your toolbox (the search textbox, I assume)?

    could you try having the search box pass a querystring to the url, and grab it from there?

    if i've misunderstood your question, please let me know, and I'll do what I can to help!
    Answered
  3. Daniel
    Daniel avatar
    62 posts
    Registered:
    20 Apr 2009
    12 Aug 2009
    Link to this post
    Hi SelArom

    Thanks for your reply and you know what I never even thought about Querystrings!!!

    I will have a go and see how it turns out thank you very much.

    Just to answer your question I was trying to do it the other way as in on the button click (the search button) I was trying to modify the SQL Statement and then rebind the gridview! Therefore trying to access the gridview fom the toolbox  user control.

    Hope that clears things up and your Idea would be much better!

    Thanks again

    Daniel

    Edit: Yes the querystring idea worked like a charm I now have slight problem with a placeholder visibility i didnt think about!!

    Basically i have a placeholder that has visibility set to false - then when you click on the link it sets the visibility to tru and you can perform the search however when you click search it performs the search perfectly but then the placeholders visibility reverts back to false is there any way of keeping it true. Again probably a very simple answer just need to step away from it for an hour or so I think!!

    Thanks agin for your help!
  4. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    12 Aug 2009
    Link to this post
    do you set the visibility to false on page load of the code behind? try setting it on the control itself. it might be that the visibility is resetting. also make sure that enableviewstate is not disabled, because that will also prevent it from keeping it's status.

    you can also use the IsPostBack property to check if you're reposting to the form and skip the visibility setting...

    hope that made sense!
  5. Daniel
    Daniel avatar
    62 posts
    Registered:
    20 Apr 2009
    12 Aug 2009
    Link to this post
    Looks like I looked here at the right time!!!

    I was just about to say I have managed to suss it out I was setting it on the property itself and then on postback It was reverting back to invisible.

    So I saved the setting on a session and then on load checked the session variable as to what it was and set it back to that!!!

    Not sure if that is a good way to do it but it works! if there is a better way could you give me some sample code if poss?

    Thanks for all your help with this matter!

    Daniel
  6. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    12 Aug 2009
    Link to this post
    assuming that you're changing it's property on the Click Event, you shouldn't need the session. Changes in asp.net controls are maintained automatically using ViewState (a hidden variable on the page), so if you set Visible=False on the control at the page level, then on Click you change it to Visible=true, it should stay visible because the Viewstate will be updated when the event fires. So you should be able to remove any code on pageload that changes the visibility...

    however all of this assumes you are posting to the page to make your search. If you are redirecting (which it sounds like you are, since you're using a querystring) then you would have to use another method. I would suggest instead of using the session, simply check if the query string is present and has a value. If so, then a search was performed, so the search box should be visible. you can even populate the search box with the parameter so users can see what was searched.

    hope that helps!
    Answered
  7. Daniel
    Daniel avatar
    62 posts
    Registered:
    20 Apr 2009
    12 Aug 2009
    Link to this post
    Very valid point!

    I shall get onto it know thank you for your help with this!

    Daniel
  8. Nitesh Rastogi
    Nitesh Rastogi avatar
    15 posts
    Registered:
    24 Aug 2009
    07 Sep 2009
    Link to this post

    Posted 2 days ago (permalink)

    Hi,

    My requirement is that i need to create a new modulle, which i have done taking help of developer manual.Know what i want is that give the business user an option to select the no of controls (may be one or two) and based on the selected number  generate  Rad Editor and display on the control panel  of the module at that time.Then the user fills the content in the editor and saves the same for one/two controls generated.Following is the code which i have written in the ControlPanel.ascx file but i do not get to see the rad controls generated.Do i have to add the contrls to the container.What would be the code for that.
    protected void ddNoOfControls_SelectedIndexChanged(object sender, EventArgs e)  
        {  
            int noOfControls = 0;  
            noOfControls = Convert.ToInt32(ddNoOfControls.SelectedValue);  
            for (int i = 0; i <= noOfControls; i++)  
            {  
                Telerik.Web.UI.RadEditor radEditor = new Telerik.Web.UI.RadEditor();  
                radEditor.ID = "RadEditor" + i+1;  
                radEditor.Visible = true;  
            }  
     
        } 


    How do i accomplish this .
    Thanks

  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Sep 2009
    Link to this post
    Hi Nitesh Rastogi,

    As I see it you are using DropDownList control and depending on a selected value you are creating dynamically RadEditor control. It will be better option if you add your logic in one of the views you are creating under your Control Panel. Also I could not see where you are adding your contorl to Controls collection -  Controls.Add(YourControlHere); Since you are going to use dynamically added controls you cannot use a container. You can use a container when you have a template for your control/view with declared controls in this template. Then you instinate this template and get all controls you want to add to this container.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
9 posts, 2 answered