|
bhanu12345 wrote: I wanted to is it possible for me to call a javascript function on clicking update button in datagrid.
It is not a good practice.
Go with Ajax. that will be better for this.
Regards,
Satips.
|
|
|
|
|
Hi,
I am getting an error while uploading and deleting a file in the server. Using the following code.
ERROR MESSAGE: The process cannot access the file 'index_01.jpg' because it is being used by another process.
protected void Button4_Click(object sender, EventArgs e)
{
DirectoryInfo d = new DirectoryInfo(Server.MapPath("~\\Upload\\"));
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(@"D:\\Dotnet_Projects\\kyc_start\\Upload\\" + FileUpload1.FileName);
}
else
{
Label1.Text = "No File Uploaded.";
}
foreach (FileInfo f in d.GetFiles("*.jpg"))
{
byte[] buffer = new byte[f.OpenRead().Length];
f.OpenRead().Read(buffer, 0, (int)f.OpenRead().Length);
PhotoManager.AddPhoto(buffer);
f.Delete(); //ERROR HERE!!!
}
this.PhID();
}
Plz let me know where i am making mistakes. ITS working fine in local server.
Regards,
dhulipudi
|
|
|
|
|
My guess is that your site is still running or perhaps your app pool is still running. Normally when you delete files that belong to a web site you will need to stop the web site and the app pool to make sure that none of the files are cached in memory. So if you shut down the app pool that your web app is using I think you should be able to delete the file.
Hope that helps.
Ben
|
|
|
|
|
Hi Ben,
I would like to explain my task more clearly...
Task: Upload Client photos to server and display it. (registration form)
Strategy followed:
1. Upload images to \upload\ folder in server.
2. Read all images in \upload\ folder and put it in sql database.
3. delete the image from \upload\ folder.
4. display it in the webform.
All this tasks should perform in a single button click "upload image"
I succeeded In SETPS: 1, 2 and 4.
I could not delete the file (step 3) soon after I upload the file into the database.
IN this situation i could not stop the site for deletion I need some suggestions that can delete the file soon after Step 2.
Plz let me know your thoughts.
Regards,
JJ
|
|
|
|
|
I am not sure what code you are using to read the images, but I would guess there is a chance that code is not properly closing its connection to the image it just read. The only other thing I have seen with images is the need to call garbage collection. So after you read the images and close the connections to the image then you may need to call gc.Collect
Hope that helps.
Ben
|
|
|
|
|
Here is an example of openread with a fileinfo
using (FileStream fs = fi.OpenRead())
{
byte[] b = new byte[1024];
UTF8Encoding temp = new UTF8Encoding(true);
while (fs.Read(b,0,b.Length) > 0)
{
Console.WriteLine(temp.GetString(b));
}
}
When the using is used the openread is closed when you reach the end of the using. So you are not closing your openread.
Ben
|
|
|
|
|
Thank you for the info. I will check once again all my connections and stream readers used to read the images to DB.
Regards,
Jagadeesh
|
|
|
|
|
dhulipudi wrote: foreach (FileInfo f in d.GetFiles("*.jpg"))
{
byte[] buffer = new byte[f.OpenRead().Length];
f.OpenRead().Read(buffer, 0, (int)f.OpenRead().Length);
PhotoManager.AddPhoto(buffer);
f.Delete(); //ERROR HERE!!!
}
A quick brainstorming query: Did you observe whether this FileInfo keeps an handle also?
|
|
|
|
|
I want to know how should we give validation for phone numbers.
my phone number format is 0000-000-000
|
|
|
|
|
There are a couple of easy ways
1. Client-side
There is a nice ASP.net AJAX control in the toolkit which offers this if you want to use it. Link - http://ajax.asp.net/ajaxtoolkit/MaskedEdit/MaskedEdit.aspx[^]
2. Regular expression validator
You could write a simple regular expression to match the input against and use a validator on the page. The regular expression would be something like
^d{4}-\d{3}-\d{3}$ (Not 100% sure of the exact syntax)
Try www.regexlib.com as a great source for help and examples of regular expressions.
|
|
|
|
|
|
Heared of Regular expression ?
|
|
|
|
|
Here is your code for Validation of Phone Number, with asp:regularexpressionvalidator
<%@ Page Language=VB Debug=true %>
<title>Validating a Phone Number with a RegularExpressionValidator Control
Please enter your phone number:
<asp:textbox
="" id="txtPhoneNumber" runat="server">
<asp:regularexpressionvalidator
="" id="regZipCode" controltovalidate="txtPhoneNumber" validationexpression="\\d{4}\-\d{3}\-\d{3}" display="Dynamic" font-name="Arial" font-size="11" runat="server
">
You must enter a phone number in the form of 9999-999-999.
<asp:button
="" id="butOK" text="OK" type="Submit" runat="server">
Regards,
Satips.
|
|
|
|
|
|
Thanks, but if the first number should be either 3 or 4 so how should we give?
like 0000-000-000 or 000-000-000
|
|
|
|
|
The first digit is only three.
Like wise you have to mention.
(999) 999-9999.
Regards,
Satips.
|
|
|
|
|
But i have given the code as you have asked for four digit in the first as you stated.
If you want you can change the code for three.
Regards,
Satips.
|
|
|
|
|
Thanks .Can we keep both either 3 or 4 in single expression.because some phone no is having 4 digit first and some having 3 digit first.
|
|
|
|
|
A kamath wrote: Can we keep both either 3 or 4 in single expression.because some phone no is having 4 digit first and some having 3 digit first.
Not Both at a time go with any one.
Mostly the standard format is (999) 999-9999. like this only.
The first three numbers inside braces denotes the Code and the other seven numbers will represents the other.
Everywhere you see only 10 didgit phone number only.
Regards,
Satips.
|
|
|
|
|
|
Welcome
Regards,
Satips.
|
|
|
|
|
Hi
what is the property name for reading 'web page' of the user from active directory.
may i have complete list of the property for windows server 2003?
Thank you
Jayesh Talsaniya
Jayesh Talsaniya
|
|
|
|
|
hi all
dt is datatable
if i assign
session["demo"] = dt;
datatable have 100 rows data
so where will The data in session["demo"]("100 rows data") store ?? Server or client site
And where is position data store ??
|
|
|
|
|
You really should not do this.
The session data is stored on the server (only the session ID is passed back and forth between client and server as a cookie - the server can then use this ID to retrieve the relevant session data.)
You should only ever store small amounts of data in your session object - imagne the server resources consumed if you have, say, 100 sessions at once... imagine 1,000 sessions.... imagine your server siezing up...
Fred
|
|
|
|
|
thank all reply to me
i could understand is
if i have datatable (dt) contain 100 rows
and i assign session["demo"] = dt;
Data in Session["demo"] mean is 100 rows data have store in server and client will have session id of itseft on server
when client request to server on the server will check session id on client with session id on server and then assgin data by session store on server;
ex: datatable dt1 = (datatable)session["demo"];
but i dont know if data of session store on server so where is it store ???
|
|
|
|