|
Hi,
Currently, in my ASP .Net project, I read text from a text file using a streamreader. The code I use is below:
<br />
<% <br />
Dim sR As New IO.StreamReader(IO.Path.Combine(Server.MapPath("~"), "templates/menu.txt"))<br />
Do<br />
Dim line As String = sR.ReadLine<br />
Response.Write(line)<br />
Loop Until (sR.EndOfStream = True)<br />
<br />
sR.Close()<br />
%><br />
Will an exception be thrown if two separate people access the same page at the same time, thereby causing two streamreaders to try and access the same file?
Thanks in advance,
Mitch
-- modified at 14:15 Friday 9th November, 2007
|
|
|
|
|
I believe that this is OK. A file can be accessed by more than 1 process, as long as another process has not locked or prohibited read access to the file. If you were writing to a file, you would want to lock all or part of it to ensure that your changes were not overwritten by another process.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Great, thanks for the reply.
I wasn't sure how Windows would handle two separate read requests at the same time.
Thanks,
Mitch
|
|
|
|
|
Hi,
I want to ask about the (log in) in the VB2005..
how I can use the administration tools from Asp.net configuration ?? because when I enter to administration tools and go to the security tab , the message will be occur “ unable to connect to the DB !! “
how I can solve this problem ??
Thanks..
|
|
|
|
|
You probably do not have a SQL Server installed on your machine. Try installing the express edition of SQL Server and let me know if you are still not able to use Admin tools.
Best Regards,
Sam Xavier
www.componentone.com
|
|
|
|
|
hi ,
I have created a data grid and also connected to database ( in sql server) . my data grid table consists of few rows and columns . my each row shud be updated by modfying the row creating a edit box there in the page displayed when u click the edit button!! i want to edit each row and then update existing record of the table ..
i am working in VS 2005 and using sql server manager for my database ..
can somebody explain me each step clearly how to do this !!!
thank you
|
|
|
|
|
1. Convert all bounded columns to the template columns.
2. Add a Link and set the commandname "Edit" in normal template..
3. Add another link in edit template and set the commandname "update"
4. In Datagrid_ItemCommand event,
<br />
if(commandname = "edit"){<br />
}<br />
else if(commandname = "update"){<br />
}
That's all..
|
|
|
|
|
can u explain in detail how to do that.. i am not able to do it still
|
|
|
|
|
Those steps that I mentioned are the details.. I currently don't have the sample code for this..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
VS 2005 Pro SP1 on Win XP.
I get the above error occasionally on attempting to save a web form. Clicking on OK triggers the Save As dialog box. At this point the only solution is to save it to another location, then quit VS, copy the saved file back to its original location (i.e., overwrite the corrupted original) and then restart VS.
I've seen that others have had this problem but on older versions of VS. So far, I've only noticed it happening on the same specific file. This is a file I've inherited from another developer and contains user controls and Ajax controls.
I also have these IDE add-ins - Refactor! Pro/DXCore, GhostDoc, SmartPaster, CodeKeep, Resharper UnitRun.
Any ideas?
Kevin
|
|
|
|
|
I have a search option in my page how can I control the words that are in the list when the user types something.
I have different pages I need to get the relevant words to this page.
thx
BiG RaLpH
|
|
|
|
|
|
I need several buttons on each GridView row that redirect to pages performing custom operations. How do I get the DataKey of the row the button was clicked on? So that I can send the database ID of the row I want to perform operations on to another page. I can't use GridView.SelectedDataKey.Value because i'm not always going to be clicking the select button. Nor can I use the index, because that is not the ID for the data in the database.
|
|
|
|
|
Nevermind. This is how I did it. If someone knows a better way, lemme know.
I created a button commandField with command "EditRow" and hooked up the RowCommand event.
<code>
protected void MainGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EditRow")
{
DataKey mykey = MainGrid.DataKeys[Convert.ToInt32(e.CommandArgument)];
String mystring = Convert.ToString(mykey.Value);
Page.Response.Redirect("Insert.aspx?key=" + mystring);
}
}
</code>
|
|
|
|
|
I m in need of list of asp.net project title for my academic , can any one help me.
prabumj@gmail.com
|
|
|
|
|
How's about a project title cataloguing and listing application?
|
|
|
|
|
I See two problem.
1st: Wrong forum, try Longue
2snd: You didn't say witch language you gonna use.
My Suggestion:
If you must have asp.net, then try Database manager or news control.
|
|
|
|
|
I have added the script below to my website and if it is in test mode, it works fine - it writes the data to the screen. But when I take it out of test mode, it doesn't email me the data. I have pasted the script along with my code for the form. Can someone please tell me why it's not emailing? (Also, fyi, I do have a .txt file setup for the formatting of the email.) Thank you!
ASP Script named sendmail_cdo.asp
<%
option explicit
'---------------------------------------------------------------------------------------------------
'FORM MAIL SCRIPT
'----------------
'usage:
'<form ACTION="sendmail.asp" ...>
'
'hidden fields:
' redirect - the url to redirect to when the mail has been sent (REQUIRED)
' mailto - the email address of the recipient (separate multiple recipients with commas) (REQUIRED)
' cc - the email address of the cc recipient (separate multiple recipients with commas) (OPTIONAL)
' bcc - the email address of the bcc recipient (separate multiple recipients with commas) (OPTIONAL)
' mailfrom - the email address of the sender (REQUIRED)
' subject - the subject line of the email (REQUIRED)
' message - the message to include in the email above the field values. not used when a template is being used. (OPTIONAL)
' template - specifies a text or html file to use as the email template, relative to the location of the sendmail script. (e.g. ../email.txt)
' A template should reference form fields like this: [$Field Name$]
' html - if this has the value "yes", the email will be sent as an html email. only used if a template is supplied.
' testmode - if this is set to "yes", the email contents will be written to the screen instead of being emailed.
'---------------------------------------------------------------------------------------------------
dim pde : set pde = createobject("scripting.dictionary")
'---------------------------------------------------------------------------------------------------
'PREDEFINED ADDRESSES for the "mailto" hidden field
'if you don't want to reveal email addresses in hidden fields, use a token word instead and specify
'below which email address it applies to. e.g. <input type="hidden" name="mailto" value="%stratdepartment%">
'ALSO, in the same way, you can use %mailfrom% to hide the originating email address
pde.add "%contactform%", "myemail@someaddress.com"
pde.add "%salesenquiry%", "anotheremail@someaddress.com"
'---------------------------------------------------------------------------------------------------
function getTextFromFile(path)
dim fso, f, txt
set fso = createobject("Scripting.FileSystemObject")
if not fso.fileexists(path) then
getTextFromFile = ""
exit function
end if
set f = fso.opentextfile(path,1)
if f.atendofstream then txt = "" else txt = f.readall
f.close
set f = nothing
set fso = nothing
getTextFromFile = txt
end function
dim redir, mailto, mailfrom, subject, item, body, cc, bcc, message, html, template, usetemplate, testmode
redir = request.form("redirect")
mailto = request.form("mailto")
if pde.exists(mailto) then mailto = pde(mailto)
cc = request.form("cc")
bcc = request.form("bcc")
mailfrom = request.form("mailfrom")
if mailfrom = "" then mailfrom = pde("%mailfrom%")
subject = request.form("subject")
message = request.form("message")
template = request.form("template")
testmode = lcase(request.form("testmode"))="yes"
if len(template) > 0 then template = getTextFromFile(server.mappath(template))
if len(template) > 0 then usetemplate = true else usetemplate = false
dim msg : set msg = server.createobject("CDO.Message")
msg.subject = subject
msg.to = mailto
msg.from = mailfrom
if len(cc) > 0 then msg.cc = cc
if len(bcc) > 0 then msg.bcc = bcc
if not usetemplate then
body = body & message & vbcrlf & vbcrlf
else
body = template
end if
for each item in request.form
select case item
case "redirect", "mailto", "cc", "bcc", "subject", "message", "template", "html", "testmode"
case else
if not usetemplate then
if item <> "mailfrom" then body = body & item & ": " & request.form(item) & vbcrlf & vbcrlf
else
body = replace(body, "[$" & item & "$]", replace(request.form(item),vbcrlf,"<br>"))
end if
end select
next
if usetemplate then 'remove any leftover placeholders
dim rx : set rx = new regexp
rx.pattern = "\[\$.*\$\]"
rx.global = true
body = rx.replace(body, "")
end if
if usetemplate and lcase(request.form("html")) = "yes" then
msg.htmlbody = body
else
msg.textbody = body
end if
if testmode then
if lcase(request.form("html")) = "yes" then
response.write "<pre>" & vbcrlf
response.write "Mail to:" & mailto & vbcrlf
response.write "Mail from:" & mailfrom & vbcrlf
if len(cc) > 0 then response.write "Cc:" & cc & vbcrlf
if len(bcc) > 0 then response.write "Bcc:" & bcc & vbcrlf
response.write "Subject:" & subject & vbcrlf & string(80,"-") & "</pre>"
response.write body
else
response.write "<html><head><title>Sendmail.asp Test Mode</title></head><body><pre>" & vbcrlf
response.write "Mail to: " & mailto & vbcrlf
response.write "Mail from: " & mailfrom & vbcrlf
if len(cc) > 0 then response.write "Cc: " & cc & vbcrlf
if len(bcc) > 0 then response.write "Bcc: " & bcc & vbcrlf
response.write "Subject: " & subject & vbcrlf & vbcrlf
response.write string(80,"-") & vbcrlf & vbcrlf & "<span style=""color:blue;"">"
response.write body & "</span>" & vbcrlf & vbcrlf
response.write string(80,"-") & vbcrlf & "**END OF EMAIL**</pre></body></html>"
end if
else
msg.send
response.redirect redir
end if
set msg = nothing
%>
Form page...
<form name="form1" method="post" action="sendmail_cdo.asp">
<div align="left">
<p class="style3">
<input name="redirect" type="hidden" id="redirect" value="surveycomplete.htm">
<input name="mailto" type="hidden" id="mailto" value="melissawaldrop@comcast.net" />
<input name="subject" type="hidden" id="subject" value="New Inquiry">
<input name="template" type="hidden" id="template" value="contactform.txt">
<input name="testmode" type="hidden" id="testmode" value="no">
</p>
<p class="style3">First Name
<input name="FName" type="text" id="FName">
Last Name
<input name="LName" type="text" id="LName">
</p>
<p class="style20"><span class="style3"><span class="style31">Email</span>
<input name="Email" type="text" id="Email">
<span class="style31">Phone </span>
<input name="Phone" type="text" id="Phone">
</span> </p>
<p>
<input type="submit" name="Submit" value="Send">
</p>
</div>
</form>
|
|
|
|
|
This is the ASP.NET forum. You should post your question in the Web Development forum.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I am getting the error:
The process cannot access the file 'D:\KBF\WebSite\Project\KBF20071109\Images\Icon_Restricted.gif' because it is being used by another process
while trying to replace it with a new one. The reason is because it is currently displayed in an Asp:Image control. I want to replace it while it is being displaed. I tried to replace it in a button's click event just after reseting the Image control's path in the same event but the same error.
|
|
|
|
|
Hello
I can't send email.
What is smtp server? What is host name?
I know my mail server ip, my email's user and pass.
Now how can i send mail to users and get their feedback.
I test many states but i failed...
Example::
My Email : info@mysite.com
Target User : user@yahoo.com
My Server : www.mellihost.com
Server Ip : 70.84.176.94
Now please help me.
Regards
|
|
|
|
|
You can ask your hosting company about the address of smtp srv.. normally, it works with localhost..
|
|
|
|
|
Ok, But my host couldn't help me well.
Can you send some code using my sample options to help me?
Tanks
|
|
|
|
|
|
Hello
Dear Michael
I'm a professional desktop developer (C# base), but in sending mail, i really confused.
I developed a website for somebody and i'm in final step.
As you said and in this way anybody can send email from anybody to anybody..!
I want to say that: Do i need username, password and real host name or not?
I tested this code and i saw no mail in my inbox. Please notice that i made no change on your code.
So please help me again if you have time.
Tanx
|
|
|
|