Re: Unable to pass Virtual path

  •  12-06-2010, 8:57 PM

    Re: Unable to pass Virtual path

    Hi Khansaab,
     
    1. Create a page name "PageA.aspx" use the code below
     
    1. <%@ Page Language="c#" %>  
    2.   
    3. <%@ Register TagPrefix="DotNetGallery" Namespace="DotNetGallery" Assembly="DotNetGallery" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    5.   
    6. <script runat="server">    
    7.     string virtualDirectory = null;  
    8.     protected override void OnLoad(EventArgs e)  
    9.     {  
    10.         using (DotNetGallery.GalleryDataProvider provider = DotNetGallery.GalleryDataProvider.CreateInstance(Context, "~/GalleryFiles/"))  
    11.         {  
    12.             virtualDirectory = provider.VirtualDirectory;  
    13.         }  
    14.         base.OnLoad(e);  
    15.     }  
    16.   
    17. </script>  
    18.   
    19. <html xmlns="http://www.w3.org/1999/xhtml">  
    20. <head id="Head1" runat="server">  
    21.     <title>Untitled Page</title>  
    22. </head>  
    23. <body>  
    24.     <form id="form1" runat="server">  
    25.         Selected Virtual Path :  
    26.         <asp:Label ID="label1" runat="server"></asp:Label><br />  
    27.         <input type="button" value="Get virtual path" onclick="getVirtualPath()" />  
    28.         <input type="button" value="Pass VirtualPath to PageB" onclick="passVirtualPath()" />  
    29.         <DotNetGallery:GalleryBrowser ID="galleryBrowser1" runat="server" AllowEdit="true"  
    30.             Layout="Explorer" />  
    31.         <a href="" onclick="thegallerybrowser.ShowEditor();return false;">Admin Console</a>  
    32.     </form>  
    33. </body>  
    34. </html>  
    35.   
    36. <script>    
    37. function setValue() {  
    38.     var label1 = document.getElementById('<%= label1.ClientID %>');  
    39.     if (thegallerybrowser.Layout._selectedcategory) {  
    40.         if (thegallerybrowser.Layout._selectedcategory.CategoryID == null) {  
    41.             label1.innerHTML = "<%= virtualDirectory%>" + "Category0";  
    42.         }  
    43.         else {  
    44.             label1.innerHTML = "<%= virtualDirectory%>" + "Category" + thegallerybrowser.Layout._selectedcategory.CategoryID;  
    45.         }  
    46.         return true;  
    47.     }  
    48.     else {  
    49.         alert("Please select a category");  
    50.         return false;  
    51.     }  
    52. }  
    53.   
    54. function getVirtualPath() {  
    55.     setValue()  
    56. }  
    57.   
    58. function passVirtualPath() {  
    59.     if (setValue()) {  
    60.         window.location = "PageB.aspx?path=" + label1.innerHTML;  
    61.     }  
    62. }  
    63.   
    64. </script> 
     2. Create a page name "PageB.aspx" use the code below
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    4.   
    5. <script runat="server">  
    6.     protected override void OnLoad(EventArgs e)  
    7.     {  
    8.         if (Request.QueryString["path"] != null)  
    9.         {  
    10.             lbVirtualPath.Text = Request.QueryString["path"].ToString();  
    11.         }  
    12.         base.OnLoad(e);  
    13.     }  
    14. </script>  
    15.   
    16. <html xmlns="http://www.w3.org/1999/xhtml">  
    17. <head runat="server">  
    18.     <title>Untitled Page</title>  
    19. </head>  
    20. <body>  
    21.     <form id="form1" runat="server">  
    22.         <div>  
    23.             <asp:Label ID="lbVirtualPath" runat="server"></asp:Label>  
    24.         </div>  
    25.     </form>  
    26. </body>  
    27. </html> 
     3. Run "PageA.aspx" select a category and than click on the "Pass VirtualPath to PageB" button
     
    Regards,
     
    Ken
View Complete Thread