Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prompt User for Directory Path

Status
Not open for further replies.

StephDN

MIS
Nov 13, 2001
8
US
I am using Crystal Reports for Visual Studio.NET and I want the User to be able to export the Report to Excel. Exporting is not a problem. However, I need a FILE DIALOG BOX to pop up so that the User can select WHERE to put the file and then I can use that path to export. I can't hard code it (c:\Filename\...) because it will remain on our server and not save to the client machine. I can't use the <input type=file> because it is asking for a file that already exists. I just need a simple &quot;Get Directory&quot; dialog box. Any suggestions/ideas?? Thanks in advance!!
 
Just add a javascript function to the &quot;OnClick&quot; attribute of the button you click to export the report.
The javascript function would have an input{'bla bla'); line that will return a string with the path inserted by the user.
hth Daren J. Lahey
Just another computer guy...
 
I don't mean to sound simple, but I need a little more guidance. I know I can do an &quot;OnClick&quot; event for the button, but what kind of event am I creating?? I don't know what type of function will cause a Common Dialog box to appear for them to navigate/choose the folder where they want to place the file (that doesn't exist yet), and then allow me to refer to that path in my vb code for export. What type of <input> control would I be utilizing in the OnClick event to trigger the dialog box?
 
For deeper explanation on javascript you could ask in the javascript forum, But this is how I would do it

[c# in the page load event]
btnMyButton.Attributes.Add(&quot;OnClick&quot;,&quot;javascript: return myFunction();&quot;);

[in the html code]
<SCRIPT LANGUAGE=&quot;Javascript&quot;>
<!--
function myFunction()
{

string strPath;
string strResult;

strPath= input('Where would you like to export the file to?');

if(strPath<>'')
{
strResult = strPath;
}
else
{
Alert('You need to input a valid path');
myFunction();
}

Document.Form1.HiddenText.Value = strResult;
return
}
-->

or something similar (i'm not a javascript savvy hehehe).
hth
Daren J. Lahey
Just another computer guy...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top