|
Rank: Member Groups: Member
Joined: 10/24/2010 Posts: 14
|
Hello, In my test.aspx page I have: Button1 + TextBox1 and dialog control that call an Explorer.aspx, The Explorer.apx is the same provided with demo of eo.web. When I click on the button the dialog is opened and I can explore all fill on the server. When I click OK button the dialog is closed. Now, I want when click on Ok button the dialog return the name or the path of selected file, and set text of TextBox1 with this name or path. How can I do it with JavaScript or C# Thanks in advance of any answer. Best regards, Md PS:code source of my page:
Code: HTML/ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="upload_work.aspx.cs" Inherits="upload_work" %>
<%@ Register assembly="EO.Web" namespace="EO.Web" tagprefix="eo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<script type="text/javascript">
function file_selected(Explorer1) {
//I've tried this function but didn't work
var selectedFile = Explorer1.getSelectedFile();
document.getElementById("TextBox1").value = selectedFile;
}
</script>
<div>
</div>
<eo:Dialog ID="FileExplorerDialog1" runat="server" AcceptButton="OK"
AllowResize="True" CancelButton="Cancel" CloseButtonUrl="00020440"
ControlSkinID="None" HeaderHtml="Dialog Title"
HeaderHtmlFormat="<div style="padding-top:4px">{0}</div>"
HeaderImageHeight="27" HeaderImageUrl="00020441" Height="216px" MinHeight="100"
MinWidth="150" Width="320px" ShowButton="ImageButton1" IsModal="False">
<ContentTemplate><asp:Label runat="server" ID="PathLabel"></asp:Label>
<eo:FileExplorerHolder ID="Explorer1" runat="server" Height="360px" ClientSideOnFileSelected="file_selected"
Width="710px" Url="~/Explorer.aspx">
</eo:FileExplorerHolder>
<div style="padding: 10px 10px 10px 10px; text-align: right;">
<asp:Button ID="OK" runat="server" Style="width: 80px" Text="OK"
onclick="OK_Click" />
<asp:Button ID="Cancel" runat="server" Style="width: 80px" Text="Cancel" />
</div>
</ContentTemplate>
<FooterStyleActive CssText="padding-right: 4px; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; padding-top: 4px; font-family: tahoma" />
<HeaderStyleActive CssText="background-image:url(00020442);color:#444444;font-family:'trebuchet ms';font-size:10pt;font-weight:bold;padding-bottom:7px;padding-left:8px;padding-right:0px;padding-top:0px;" />
<ContentStyleActive CssText="background-color:#f0f0f0;font-family:tahoma;font-size:8pt;padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px" />
<BorderImages BottomBorder="00020409,00020429"
BottomLeftCorner="00020408,00020428" BottomRightCorner="00020410,00020430"
LeftBorder="00020406,00020426" RightBorder="00020407,00020427"
TopBorder="00020402,00020422" TopLeftCorner="00020401,00020421"
TopLeftCornerBottom="00020404,00020424" TopRightCorner="00020403,00020423"
TopRightCornerBottom="00020405,00020425" />
</eo:Dialog>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</form>
</body>
</html>
Code: C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class upload_work : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
FileExplorerDialog1.InitialState = EO.Web.DialogState.Visible;
}
protected void OK_Click(object sender, EventArgs e)
{
}
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You are very close. Please make the following changes: 1. Remove AcceptButton="OK" from your dialog. This will prevent the OK button from raising server side event; 2. Remove ClientSideOnFileSelected="file_selected" from the FileExplorerHolder. FileExplorerHolder is not FileExplorer. ClientSideOnFileSelected is a property on FileExplorer control, but not on FileExplorerHolder control; 3. Add the OnClientClick="save_file_name" on your OK button. This causes the button to call JavaScript function "save_file_name" before posting back the page; 4. Replace your file_selected function with the following function:
Code: JavaScript
function save_file_name()
{
//Get the file explorer holder object
var Explorer1 = eo_GetObject("Explorer1");
//Get the selected file
var selectedFile = Explorer1.getSelectedFile();
//Store it in the text box
document.getElementById("TextBox1").value = selectedFile;
}
This should work for you. Please let us know if you still have any question. Thanks!
|
|
Rank: Member Groups: Member
Joined: 10/24/2010 Posts: 14
|
Thanks for your quick answer,
I've added these changes, but nothing happens, the textBox1 isn't assigned with the selected file!
May be something is missing?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Please post the full page of your modified code and we should be able to tell you what's wrong.
Thanks
|
|
Rank: Member Groups: Member
Joined: 10/24/2010 Posts: 14
|
here the new code:
Code: HTML/ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="upload_work.aspx.cs" Inherits="upload_work" %>
<%@ Register assembly="EO.Web" namespace="EO.Web" tagprefix="eo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<script type="text/javascript">
function save_file_name() {
//Get the current selected file
var Explorer1 = eo_GetObject("Explorer1");
var selectedFile = Explorer1.getSelectedFile();
//Do whatever you want to do with it. Here we
//simply put it into a textbox
document.getElementById("TextBox1").value = selectedFile;
}
</script>
<div>
</div>
<eo:Dialog ID="FileExplorerDialog1" runat="server"
AllowResize="True" CancelButton="Cancel" CloseButtonUrl="00020440"
ControlSkinID="None" HeaderHtml="Dialog Title"
HeaderHtmlFormat="<div style="padding-top:4px">{0}</div>"
HeaderImageHeight="27" HeaderImageUrl="00020441" Height="216px" MinHeight="100"
MinWidth="150" Width="320px" ShowButton="ImageButton1" IsModal="False">
<ContentTemplate><asp:Label runat="server" ID="PathLabel"></asp:Label>
<eo:FileExplorerHolder ID="Explorer1" runat="server" Height="360px"
Width="710px" Url="~/Explorer.aspx">
</eo:FileExplorerHolder>
<div style="padding: 10px 10px 10px 10px; text-align: right;">
<asp:Button ID="OK" runat="server" Style="width: 80px" Text="OK"
OnClientClick="save_file_name" />
<asp:Button ID="Cancel" runat="server" Style="width: 80px" Text="Cancel" />
</div>
</ContentTemplate>
<FooterStyleActive CssText="padding-right: 4px; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; padding-top: 4px; font-family: tahoma" />
<HeaderStyleActive CssText="background-image:url(00020442);color:#444444;font-family:'trebuchet ms';font-size:10pt;font-weight:bold;padding-bottom:7px;padding-left:8px;padding-right:0px;padding-top:0px;" />
<ContentStyleActive CssText="background-color:#f0f0f0;font-family:tahoma;font-size:8pt;padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px" />
<BorderImages BottomBorder="00020409,00020429"
BottomLeftCorner="00020408,00020428" BottomRightCorner="00020410,00020430"
LeftBorder="00020406,00020426" RightBorder="00020407,00020427"
TopBorder="00020402,00020422" TopLeftCorner="00020401,00020421"
TopLeftCornerBottom="00020404,00020424" TopRightCorner="00020403,00020423"
TopRightCornerBottom="00020405,00020425" />
</eo:Dialog>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</form>
</body>
</html>
Code: C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class upload_work : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
FileExplorerDialog1.InitialState = EO.Web.DialogState.Visible;
}
}
Thanks in advance for your support. Best regards, Md
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Sorry it's our mistake.
OnClientClick="save_file_name"
Should be:
OnClientClick="save_file_name()"
Also you should not remove OnClick handler on your OK button. You still need that.
Thanks
|
|
Rank: Member Groups: Member
Joined: 10/24/2010 Posts: 14
|
It’s work fine.
Thank you very very much. Nice to contact you.
Have a good day,
Md
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
You are welcome. Please feel free to let us know if you have any more questions.
Thanks
|
|