Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

Custom Control inheriting WebImageViewer

Last post 16 May 2007, 9:30 AM by David Cilley. 7 replies.
Sort Posts: Previous Next
  •  15 Feb 2007, 7:13 PM 11467

    Custom Control inheriting WebImageViewer

    Hi,
     

    I would like to use a WebImageViewer on Multipage TIFF, but without the ThumbnailViewer.

    So, I need to be able to implement a page management system.

    I created a custom control implementing WebImageViewer.

    I added some properties such as CurrentPage and Pagecount to be able to keep track of the pages.

    I also added a changePage method that will update the CurrentPage property and will reload  the image at CurrentPage.

    I implemented a control State system to save the properties on the server side.

     

    Now, on my aspx page, I put, say, a server side button to display the next page. If I bind this buttn with a code behind function that will call the changePage method of my custom control, this works properly but requires a full postback, which I would like to avoid.

     I tried another solution : Remote Invoking a codebehind  method from javascript; which method will call the changePage method of my custom control. The problem here, is that in this case, my custom contrl can't seem to be able to keep track of the file Name, although I added it in the control state.

     What is odd, is that the call to the same method, but from code behind perfectly works...

     
    I hope  have been clear enough.....

     

    Would you have any idea about what the problem might be ? Or do you know of any other solution to implement the change of pages without requiring PostBacks and without ThumbnailViewer ?
     

    Thanks a lot,
     

    Guillaume
     


     

     

    Filed under: , ,
  •  16 Feb 2007, 1:16 AM 11478 in reply to 11467

    Re: Custom Control inheriting WebImageViewer

    You have, unfortunately, hit upon the limitation of RemoteInvoke.  RemoteInvoke is only designed to keep track of properties and state of the parent WebImageViewer, and as such, it doesn't know about the other properties that need to be passed down through the RemoteInvoke.

    You can work around this by setting up your RemoteInvokable method to accept the state of properties that you are trying to keep track of for this specific action.  For example:

    [RemoteInvokable]
    public void ChangePageFromClientState(int pageNumber, int pageCount, (other state values necessary...){
      this.PageNumber = pageNumber;
      this.PageCount = pageCount;
      (...)

      ChangePage(pageNumber);  // call your change page method here


    David Cilley
    My AJAX Imaging Blog
    Atalasoft Development Team
  •  10 May 2007, 10:50 PM 11996 in reply to 11467

    Re: Custom Control inheriting WebImageViewer

    would you send me the source code so i can do the same thing?
    I just start to use SDK so totally new to me.

    IF you can send me some sapmple of aspx and custom control page, that will be wonderful.

     thanks,


    Young
    Founder of Medical and Web application companies
    Focus on mulitimedia processing
    FairFax, Virginia, USA
  •  15 May 2007, 11:29 AM 12023 in reply to 11996

    Re: Custom Control inheriting WebImageViewer

    I am using removeInvode in the cs behind code to OpenURL as an example.
    This function is in control.ascx.cs page. Now I have control.aspx and embeded control.ascx as below in parient page.

    <td width=700 height=500>
    <uc1:WebFormsDemoAnnotations Title="Test" name="WebFormsDemoAnnotations1" ID="WebFormsDemoAnnotations1" runat="server" />
    <br>
    <input type="image" id="IMG1" name="IMG1" src="images/Templates/businesscards/HumpbackWhale_510x295.jpg" onclick="LoadImage(this.src)" style="font; width:200px; height:140px;" />
    <input type="image" id="IMG2" name="IMG2" src="images/Templates/businesscards/Dock_500x300.jpg" onclink="LoadImage(this.src)" style="font; width:200px; height:140px;" />
    </td></tr></table>
    </form>

    <script language="javascript">
    function LoadImage(src) {
         document.all.WebFormsDemoAnnotations1.OpenUrl("images/Templates/businesscards/Dock_500x300.jpg");
    }

    </script>

    I got an error that object not found in the page due to that custom control's name and ID are changed which I don't have control of it. Am I corectly calling control by javascript or not?
    Once I have OpenURL function as a removeinvokable, how to call this function from parent aspx page?

    [RemoteInvokable]
    public String OpenFile(String file) { }

    Thanks, 

     


    Young
    Founder of Medical and Web application companies
    Focus on mulitimedia processing
    FairFax, Virginia, USA
  •  15 May 2007, 2:21 PM 12024 in reply to 12023

    Re: Custom Control inheriting WebImageViewer

    You should not access the WebImageViewer through document.all or other such dom scripting means.  The primary method of interacting with the WebImageViewer is by the ClientID assigned by ASP.NET or the ID that was assigned by you (or automatically generated).

    LoadImage should look something like this (if WebAnnotationViewer1 is the id of the WebAnnotationViewer):

    function LoadImage(src) {
         WebFormsDemoAnnotations1_WebAnnotationViewer1.OpenUrl(src);
    }

    Please also make sure that you are using the latest version of DotImage (5.0.2690)


    David Cilley
    My AJAX Imaging Blog
    Atalasoft Development Team
  •  15 May 2007, 6:19 PM 12030 in reply to 12024

    Re: Custom Control inheriting WebImageViewer

    my version of dotImage is 5.0.2659.39320.

    where can I get latest version then?

     

     


    Young
    Founder of Medical and Web application companies
    Focus on mulitimedia processing
    FairFax, Virginia, USA
  •  15 May 2007, 10:12 PM 12032 in reply to 12024

    Re: Custom Control inheriting WebImageViewer

    it worked. however I have another problem to load new image when I called puclic function of ascx custom control page from javascipt on parent page. Here is the js code in aspx page.

     <script language="javascript">

    function LoadImage(src)

    {

    try{

    WebFormsDemoAnnotations1_WebImageViewer1.OpenUrl(src); //working

    WebFormsDemoAnnotations1_WebImageViewer1.RemoteInvoke('OpenFile', new Array(src)); //not working

    WebFormsDemoAnnotations1_WebImageViewer1.RemoteInvoked = Invalidate; //not working

    }catch(e){ alert(e);}

    }

    </script>

     

    Quesiton is why calling public function, RemoteInvoke('OpenFile', new Array(src)),  is not working? Am I missing some here?
    I copied this javascript function from your demo page.

    What I like to do is I like to load images from ASPX parent page by javascript to avoid page load again. I am trying to accomplish image loading just like AJAX based uploading to avoid rebuild page from the scratch.

    Thanks,


    Young
    Founder of Medical and Web application companies
    Focus on mulitimedia processing
    FairFax, Virginia, USA
  •  16 May 2007, 9:30 AM 12037 in reply to 12032

    Re: Custom Control inheriting WebImageViewer

    The public method has to be marked with [RemoteInvokable].

    I have locked this thread, as it is now discussing the same topic as this thread, and is off the original topic.


    David Cilley
    My AJAX Imaging Blog
    Atalasoft Development Team
View as RSS news feed in XML