|
Hello, I'm new to ASP.NET, so please be patient.
I need to have a download page that serves a Save As dialog when user clicks the button, but I don't know how to go about modifying the code I found on the internet.
<br />
Response.Clear()<br />
Response.AppendHeader("content-disposition", "attachment; filename=ap_06_fulldress.jpg")<br />
Response.ContentType = "text/plain"<br />
Response.WriteFile(Server.MapPath("/downloads/wallpapers/ap_06_fulldress.jpg"))<br />
Response.Flush()<br />
Response.End()<br />
I would like to pass filenames as variables to reuse the code as much as possible instead of having a function for each download, which would not be very efficient.
Any help appreciated. Thanks.
Jay
|
|
|
|
|
if you want to pass filename as variable than this would help
first sava your filename in variable like
string filename="/downloads/wallpapers/ap_06_fulldress.jpg";
now pass this variable in place of file like
Response.Clear()
Response.AppendHeader("content-disposition", "attachment; filename=ap_06_fulldress.jpg")
Response.ContentType = "text/plain"
/*** change ***/
Response.WriteFile(Server.MapPath(filename))
/*** ***/
Response.Flush()
Response.End()
In this way you can change the filename as u like just pass the filename in variable and the code will work...
viral
|
|
|
|
|
hi guys
I have one master file and all its content pages. Now i want to open new form in which i can write code for uploading file. But new form should be open in new window. which can be fix in size and after uploading file i can close that and values of file that i have upload should come in the grid view that i have in form.
Please help me if any one have any idea.
DJ
|
|
|
|
|
use window.showdialogmodal()
when you close the dialog
-- submit your master form if any values from server is needed else just do further proceedings
Regards,
Akhilesh Yadav
|
|
|
|
|
hi thanks
i am developing my project in ASP.NEt with VB so i am not able to find any window object. Could you tell me what should i exactly do???
DJ
|
|
|
|
|
Hi all! If I need to send mails from my system through ASP.NET. What do I need to do.I know about Mail classes and namespaces. Also tried giving permission to localhost in IIS for routing mails.But mails keep getting queued up in various folders of IIS they did not get delievered so what are the steps need to be done apart from coding.
Thanks
Don't Quit
|
|
|
|
|
hi there
this code works fine with me so try it ... maybe it would help
Dim mail As New System.Web.Mail.MailMessage
mail.BodyFormat = MailFormat.Html
mail.From = "mail@company.com"
mail.To = "mail@company.com"
mail.Subject = "Mymail"
Dim bod As String = "The message that you want, u can use html tags if u like"
mail.Body = bod
System.Web.Mail.SmtpMail.SmtpServer = "mail"
System.Web.Mail.SmtpMail.Send(mail)
Best Regards
3ala2
|
|
|
|
|
hi,
but this is without authentication of the sender!!!!
Authentication is an important issue in these cases.
Can you provide a version with authentication.
regards
Jamil Abou Khalil
|
|
|
|
|
It depends on teh scenario
can u exaplain more?
Best Regards
3ala2
|
|
|
|
|
Hi there!! Thanks for your help. Your code worked with some workaround on dotnet 1.1 but on dot net2.0 I'm using following code.
'create the mail message<br />
Dim mail As New MailMessage()<br />
<br />
Try<br />
<br />
<br />
'set the addresses<br />
'to specify a friendly 'from' name, we use a different ctor<br />
mail.From = New MailAddress(TextBox1.Text)<br />
mail.To.Add(TextBox2.Text)<br />
<br />
'set the content<br />
mail.Subject = "This is an email"<br />
mail.Body = TextBox3.Text<br />
<br />
'send the message<br />
Dim smtp As New SmtpClient("127.0.0.1")<br />
<br />
smtp.Send(mail)<br />
Catch ex As Exception<br />
Label1.Text = ex.ToString<br />
End Try
I'm getting following exception
System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.<br />
at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)<br />
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)<br />
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)<br />
at System.Net.Mail.SmtpReplyReader.ReadLine()<br />
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)<br />
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)<br />
at System.Net.Mail.SmtpClient.GetConnection()<br />
at System.Net.Mail.SmtpClient.Send(MailMessage message)<br />
--- End of inner exception stack trace ---<br />
at System.Net.Mail.SmtpClient.Send(MailMessage message)<br />
at Default2.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\Try1\Default2.aspx.vb:line 25
Any help would be highly appreciated.
Don't Quit
|
|
|
|
|
I'm not sure about the framework 2.0
maybe u should use another class or change the class instance parameters
Best Regards
3ala2
|
|
|
|
|
Hi got it to work.I'm just posting the things which should be taken care of so that others could benefit.
IIS -> Default SMTP Virtual Server ->Right Click Properties -> Access Tab ->Connection (Also Relay) Add your server name (For example 127.0.0.1 localhost). It will work.
Thanks
Don't Quit
|
|
|
|
|
Great man
now we have code that works on both frameworks
Take Care
Best Regards
3ala2
|
|
|
|
|
hi all,
how to access a COM component developed in vc++6.0 from ASP.net?
what r the issues need to be considered in this case??
Thanks in advance.
Prashanth.v
-- modified at 4:59 Monday 30th October, 2006
|
|
|
|
|
Have you tried creating a typelib of the COM object or adding it to the references?
|
|
|
|
|
Hi guys
I hve problem while using datagrid.The datagrid is binded with items details from database's item table.Now wht I want to do is to search for an item. I am using a textbox and if i typed an items name in this textbox, I want to point the cursor to that particular item in datagrid .can anybody give a soln for this pls...
|
|
|
|
|
try to read something about "cursors" and the "item_created" of the datagrid
i use repeaters so i'm not a professional with data grids
hope this would help
Best Regards
3ala2
|
|
|
|
|
is there a .exe file in asp.net?
|
|
|
|
|
.exe will be generated after you deploy the web application.
Best regards,
Chee ken
|
|
|
|
|
The asp.net generated a dll for all ur classes and the webforms in the aspx format, so there are no exe files
Best Regards
3ala2
|
|
|
|
|
pls give all the objects used to store values like session,vivewstate.
i know only session,viewstateand context.Is there any more objects??
thank you
yesuprakash
|
|
|
|
|
hi there
Server side as u said sessions and viewstate and of course db
as for client side u can use the query string or cookies
Best Regards
3ala2
|
|
|
|
|
ya Session,application,cookies,viewstate,parametrize properties can be hepfull
|
|
|
|
|
I want to Fetch a particular location from google map of 5 km distance using zip code basis
I am using Google Web service.It is showing the error of Invalid key .
The code as follows:
Dim ProxyHost As String = "192.168.0.100"
Dim ProxyPort As Integer = 8080
Dim ProxyUser As String = ""
Dim ProxyPassword As String = ""
Dim ProxyDomain As String = "http://api.google.com/search/beta2"
Dim oWebProxy As System.Net.WebProxy = New System.Net.WebProxy(ProxyHost, ProxyPort)
oWebProxy.Credentials = New System.Net.NetworkCredential(ProxyUser, ProxyPassword, ProxyDomain)
' obj_wrr.Proxy = oWebProxy
'obj_wrr.Credentials = New System.Net.NetworkCredential(feedid, password)
Dim s As localhost.GoogleSearchService = New localhost.GoogleSearchService
s.Proxy = oWebProxy
Dim r As localhost.GoogleSearchResult
r = s.doGoogleSearch("", TextBox1.Text, 0, 10, False, "", False, "", "", "")
Dim strFile As String = "C:\\result.html"
Dim sw As StreamWriter = File.CreateText(strFile)
sw.WriteLine("" & Microsoft.VisualBasic.Chr(9) & "BODY { font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; font-size : 9pt; color : #000000; SCROLLBAR-FACE-COLOR: white; SCROLLBAR-HIGHLIGHT-COLOR: #003366; SCROLLBAR-SHADOW-COLOR: #003366; SCROLLBAR-3DLIGHT-COLOR: #f9f9f9; SCROLLBAR-ARROW-COLOR: #003366; SCROLLBAR-TRACK-COLOR: white; SCROLLBAR-DARKSHADOW-COLOR: #f9f9f9 }")
For Each dc As localhost.DirectoryCategory In r.directoryCategories
sw.Write("Category : ")
sw.WriteLine(dc.fullViewableName)
sw.WriteLine("
")
Next
For Each re As localhost.ResultElement In r.resultElements
Dim strTitle As String = "" + re.title + "
"
sw.WriteLine(strTitle)
Dim strSnippet As String = re.snippet + "
"
sw.WriteLine(strSnippet)
Dim strLink As String = "" + re.URL + " - " + re.cachedSize + "
"
sw.WriteLine(strLink)
sw.WriteLine("
")
Next
sw.Close()
Label1.Text = TextBox1.Text + " 's web search"
Dim estResults As Integer = r.estimatedTotalResultsCount
Dim ldTime As Double = r.searchTime
Label1.Text = "Total " + Convert.ToString(estResults) + " " + "1 - 10 seach result Total time:" + Convert.ToString(ldTime)
Dim obj As Object = Nothing
Dim di As DirectoryInfo = New DirectoryInfo(Environment.CurrentDirectory)
Dim strFilePath As String = di.FullName + "\" + strFile
WebBrowser.Navigate(strFilePath, obj, obj, obj, obj)
|
|
|
|
|
How can we implement CallOuts to a text document in web application
|
|
|
|