hi!
how to give unique id's to images in asp.net web forms.
means every image goes to images folder like. photo1,photo2,photo3.........
plz give example code to do this.
thanks.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rahul RayPosted Mar 8, 2010, 8:46 AM
Use
Following code to get the unique id
Guid guid = Guid.NewGuid;
string uniqueId=guid .Tostring();
string fileName="originalFileName"+"_"+uniqueId;
assign to this to ur file and during fileUpload.SaveAs();
give name to it.
Thanks
Rahul Deb Ray
ajay rajuPosted Mar 9, 2010, 1:43 AM
Thanks For Helping, But Here images are not goto uniform. it goes like Photo0,Photo1,Photo3,Photo6,Photo8,Photo7....
i write
Dim uniqueID As String = GenerateRandomString(StringType.Numeric, 1).ToString()
Dim filename As String = "photo" & uniqueID & ".Jpg"
How to solve This.
Amit ChoudharyPosted Mar 8, 2010, 6:39 AM
Pass no. character for random generated string and enumeration of the stringType define above.
use following function to generate the random strings and add them to your images names while uploading in your file.SaveAs() method.
Please Don't forget to mark as answer.