i want select folder using asp.net , when i click browse button it will open file selection dialog.
There is no html control for folder selection - so this is not possible with ASP.Net.
You Can Add:
1- Folder Browser Dialog (For Folder)
and use it Like This:
`if(folderBrowserDialog1.ShowDialog() != DialogResult.Cancel)
string str = DialogFolderBrows.SelectedPath;`
2- Open File Dialog (For File)
and use it Like This:
`if(openFileDialog1.ShowDialog() != DialogResult.Cancel)
string str = DialogOpenFile.FileName;`
Related
If I want to create a button for template-editor I am using this code:
#Edit.Toolbar(actions: "template-develop")
But in my template code I also use code like this:
#RenderPage("_pager.cshtml", new { count = data.pCount, active = data.pActive})
And if I want to edit this file: _pager.cshtml I have to go to the server with FTP or RDP and change this file...
Can I and how create "template-editor" button for _pager.cshtml that I can edit it inside web browser?
Wonder why you need to open it through FTP or RDP as you can edit it directly from website by clicking the template name :
This question already has answers here:
Directory Chooser in HTML page
(8 answers)
Closed 7 years ago.
I want users to be able to save files to a certain location so I need to save the folder path they want. I want to do something like the way to change the download location in Google Chrome:
I know to save a file I could use <asp:FileUpload runat="server" ID="file" />
But I just need to capture the path of the folder, not save a file. How do I do this in asp.net? Then later when I do save the file, I will have the location the file needs to go.
i think this would help you some
first you need to import windows.forms to asp.net (aspx.cs) page.
using System.Windows.Forms;
then take a button and generate an event to it.
use the code below it will show save as dialog box.
SaveFileDialog my_Sfd1 = new SaveFileDialog();
my_Sfd1.Filter = "All files (*.*)|*.*"; //here you can specify the file format.(*.*)indicates all files.
my_Sfd1.Title = "Save file to"; //Title to display at top of the dialog box
my_Sfd1.FilterIndex = 2;
my_Sfd1.RestoreDirectory = true;
if (DialogResult.OK == (new Invoker(my_Sfd1).Invoke()))
{
//add file here which you want to save.
}
When debugging my current solution, it always output to mylocalhost:port/default.aspx. How to I force it to output to another path like mylocalhost:port/Default/default.aspx?
right click on your project select properties (or press F4) and you can change port number, and virtual path like \default
You need to change it in your web application's settings (right click project and choose Settings from menu or Alt + Enter), like this:
I'm having an issue with the OpenFileDialog class, where the OpenFileDialog window will open, but only behind every other application I have running in my OS. I've been hesitant to ask about this, but my search using many different keywords on Google, and searching other forums, has turned up nil. I'm using the following code in a button click event of the button on my web form I want the user to click on to open the file dialog:
Dim fd As New OpenFileDialog()
Dim strFileName As String = ""
fd.Title = "Open File Dialog"
fd.InitialDirectory = "C:\"
fd.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
fd.FilterIndex = 2
fd.RestoreDirectory = True
If fd.ShowDialog = DialogResult.OK Then
strFileName = fd.FileName
End If
The dialog box opens - it just opens behind every other window...what am I missing here? Am I just going to have to do a funky workaround by minimizing everything when I call the OpenFileDialog class? All I need is for the window to show in front of the browser and every other window. Thanks in advance for your help!
openfiledialog has no place in a standard ASP.NET application. If you call ShowDialog on it, the dialog will open on the server computer (under what user session?) unbeknownst to user looking at the browser window on the client.
Use <input type="file" ... or FileUpload server control to let user select a file to be uploaded to the server.
I'm working with .net 4.0 in asp.net.
I have folder on web server having some pdf file, I display its (File Name) Name in gridview then i want to do "when i click on Item in grid view then it open that pdf file and generate url with file in browser."
I'm using Following Code
GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).Parent.Parent;
LinkButton hk = (LinkButton)gvFiles.Rows[row.RowIndex].FindControl("lnkbtnTitleView");
string s = Server.MapPath("~/AppName/App_" + dtFiles.Rows[0]["ENewsLetterID"].ToString() + "_1.PDF");
hk.Attributes.Add("onclick","window.open('"+s+"')");
Add ashx handler to your website, that will send pdf as content back to client. Add links to gridview, that will reference to this handler.
If the PDF file already exists simply put direct link:
string s = string.Format("/AppName/App_{0}_1.PDF", dtFiles.Rows[0]["ENewsLetterID"]);
And add window name _blank:
hk.Attributes.Add("onclick", string.Format("window.open('{0}', '_blank');", s));
Otherwise please give more details: how the PDF should be generated?