This is a migrated thread and some comments may be shown as answers.

Load var in Image manager and custom folders

5 Answers 51 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 12 Sep 2008, 06:00 PM
Hi Rumen,

I need some help to load variable inside Image manager standardalone. I send one value with one javascript to codebehind to create custom folders. I read this value in the codebehind. My problem is that the image Manager is formed at Page_Load event and the value are catched before are sent at button event, resulting null. I can't read the value at load, because if user change I need to change the folder name. Could you suggest another solution to create the image manager not in Page_Load event but during button click or similar and the good instant to load the value to create the custom folders.

Regards

5 Answers, 1 is accepted

Sort by
0
Lini
Telerik team
answered on 16 Sep 2008, 04:25 PM
Hi Pierre,

I don't think that we will be able to help you without taking a look at your code. If possible, send us the custom code you have added to the Image Manager so we can understand better what you are trying to do.

If you think the Page_Load event is too early to get your value, then you can try the LoadComplete page event:

    protected override void OnLoadComplete(EventArgs e)
    {
        //this code is executed right after page_load
        base.OnLoadComplete(e);
    }

If the LoadComplete is not working as well, you can move even further in the page life cycle and use the page PreRenderComplete event, which is the last to be executed before the page is actually rendered:

    protected override void OnPreRenderComplete(EventArgs e)
    {
        base.OnPreRenderComplete(e);
        //this code is executed just before render
    }

Regards,
Lini
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pierre
Top achievements
Rank 1
answered on 16 Sep 2008, 08:08 PM
Hi,
I try add one input hidden created client side to my Image Manager to create custom folders. The value in input hidden is read on fly from Page. No postback is allowed in my cms. I need to create the image Manager in another event for sample when button_click. I can't load value in pre Render or other event during page load because the value are not taken is null. The value is take after complete load page from one textbox where the user put some information after push the button. Thanks

Ascx
<script type="text/javascript"
    var currentTextBoxID;   
     
 
    function ImageManagerFunction(sender, args)   
    {   
        var selectedItem = args.SelectedItem;   
        var resultImageObject = args.Result;   
           
        var txt = $get(currentTextBoxID);   
        txt.value = selectedItem.getPath();   
    } 
     
    function SeeTitle() 
    { 
        var titleHidden = document.getElementById('<%= TitleValueField.ClientID %>');  
        var contitle=document.getElementById("ctl00_ContentPlaceHolder1_contolPanel_ctl00_ctl00_Title");           
        var htitle=document.getElementById("ctl00_ContentPlaceHolder1_contolPanel_ctl00_ctl00_editMetaFields_ctl00_ImgVideo1_hiddenTitle"); 
        titleHidden.value =contitle.value; 
        htitle.value=contitle.value; 
        //alert("hello"); 
        return; 
         
    } 
     
    </script> 
    <asp:HiddenField runat="server" ID="TitleValueField" />  
    <input id="hiddenTitle" type="hidden" runat="server" /> 
    <asp:TextBox ID="Linkthumb" runat="server"></asp:TextBox> 
    <telerik:dialogopener runat="server" id="DialogOpener1">   
    </telerik:dialogopener> 
   <button onclick="SeeTitle;currentTextBoxID='<%= Linkthumb.ClientID %>';$find('<%= DialogOpener1.ClientID %>').open('ImageManager');return false;">Select</button>  
  
 

cs
protected void Page_Load(object sender, EventArgs e) 
    { 
        string point_name = hiddenTitle.Value; 
        // This value are not stored is read on fly
        //Try to create custom folders
        FileManagerDialogParameters dialogParameters1 = new FileManagerDialogParameters(); 
        dialogParameters1.ViewPaths = new string[] { "~/contents/OnTrip/" + point_name + "/thumbnails/" }; 
        dialogParameters1.UploadPaths = new string[] { "~/contents/OnTrip/" + point_name + "/thumbnails/" }; 
        dialogParameters1.DeletePaths = new string[] { "~/contents/OnTrip/" + point_name + "/thumbnails/" }; 
        dialogParameters1.MaxUploadFileSize = 5000000
 
        DialogDefinition imageManager = new DialogDefinition(typeof(ImageManagerDialog), dialogParameters1); 
 
        imageManager.ClientCallbackFunction = "ImageManagerFunction"
        imageManager.Width = Unit.Pixel(694); 
        imageManager.Height = Unit.Pixel(440); 
        DialogOpener1.DialogDefinitions.Add("ImageManager", imageManager); 
    } 
0
Lini
Telerik team
answered on 18 Sep 2008, 12:34 PM
Hello Pierre,

Thank you for the provided details. Unfortunately I am still not 100% sure what your scenario does. However, I noticed a few things:

First, the button's onclick event is not set properly:
<button onclick="SeeTitle;...

you need to set it like this:
<button onclick="SeeTitle();...

Right now, the SeeTitle function is not called at all and the hiddenTitle input value is never set.

Also, it is better to use the <%= control.ClientID %> instead of pasting the full client ID of the control in the javascript code:

var htitle=document.getElementById("ctl00_ContentPlaceHolder1_contolPanel_ctl00_ctl00_editMetaFields_ctl00_ImgVideo1_hiddenTitle");

should be just:

var htitle=document.getElementById("<%= hiddenTitle.ClientID %>");

After I made sure the SeeTitle() function was executed and the hiddenTitle input value was set correctly there, the value was also present on the server in the Page_Load method. See the attached screenshot.


Best wishes,
Lini
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pierre
Top achievements
Rank 1
answered on 18 Sep 2008, 02:16 PM
Hi Lini,

My problem is not that. The value are loaded when I push the button ( is ok), The problem is that the Image Manager is created at Load_Page before pushing the button and at this momment the value are not set.
I have exe step by step, The value are called during page load. After when I go and push the button the value are setting but no more called, because the Image manager is well formed before. How to creating the Image Manager at pushing the button and no before.

Regards
0
Lini
Telerik team
answered on 19 Sep 2008, 07:51 AM
Hi Pierre,

I am sorry but we still cannot understand your scenario. If you are saying that the value

string point_name = hiddenTitle.Value;

cannot be read when you first load the page containing the image manager button, this is expected behavior. The value of the input is sent to the server only after the page makes a postback. On the initial load, the value will not be available on the server. If you are opening this page from another location, you can use some other means to send the "hiddenTitle" value to the server - e.g. as a querystring parameter when you open the page.

If this is not the case, then please open a formal support ticket and send us a working project we can deploy here and also tell us what you expect to happen when we run the project.

Best wishes,
Lini
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
Pierre
Top achievements
Rank 1
Answers by
Lini
Telerik team
Pierre
Top achievements
Rank 1
Share this question
or