|
Hi ALL,
I have folder in Server which contains some images. On page load I need to get the images and display them.
Can any one help mw how can I solve this
Thanks,
Siddiqali
|
|
|
|
|
You have to make a path to your folder, and use DirectoryInfo and FileInfo to Get the contents of the folder into the fileinfo object.
Then loop through fileinfo, and run a filter on the extension to pick out the images, plus filter out the other junk in the folder, like thumbs.db.
Dim fb_LibraryPath As String = Nothing
fb_LibraryPath = Context.Server.MapPath("\Product\images\Library\thumbs\")
Dim diFiles As DirectoryInfo = New DirectoryInfo(fb_LibraryPath)
Dim fileInfo() As FileInfo = diFiles.GetFiles("*.*", SearchOption.TopDirectoryOnly)
If fileInfo.Length() > 0 Then
For idx As Integer = 0 To fileInfo.Length() - 1
Dim fileName As String = fileInfo(idx).Name
If Not fileName.ToLower = "thumbs.db" Then
'Create a image element by code and set the src
End if
next
|
|
|
|
|
Code To upload Your Image to folder
YourFunctionToUploadImage()
{
if (ImageFileUploadControll.HasFile)
{
string fileExtention = System.IO.Path.GetExtension(ImageFileUploadControll.FileName);
if (fileExtention.ToLower() != ".jpg" && fileExtention.ToLower() != ".jpeg" && fileExtention.ToLower() != ".png")
{
lblUploadstatus.Text = "Invalid File Choose .jpg/.jpeg/.png/.gif";
}
else
{
if (File.Exists(Server.MapPath("~/Folder_Name/" + ImageFileUploadControll.FileName)))
{
lblUploadstatus.Text = "File Already Exists. Rename filename";
}
else
{
ImageFileUploadControll.SaveAs(Server.MapPath("~/Folder_Name/" + ImageFileUploadControll.FileName));
lblUploadstatus.Text = "Upload Status : File Uploaded Successfully";
}
}
}
else
{
lblUploadstatus.Text = "Please Select File";
}
}
Code To Retrive Images form Folder
PageLoadEvent()
{
DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/Folder_Name/"));
FileInfo[] fi = dir.GetFiles();
foreach(FileInfo f in fi)
{
string imageUrl = f.ToString();
Image img = new Image();
img.ImageUrl = "~/Folder_Name/"+"imageUrl";
}
}
Hope This Help
Pratik M. Bhuva
|
|
|
|
|
Hi Bhuva,
Thank you very much for your imp info. I am able to upload and get images, but while showing the images it takes long time. I have almost 150 images in the folder which I need to show with in no time. Request you to pls help me in solving this issue
Thanks,
Siddiqali
|
|
|
|
|
You can use ajax update pannel for fast image loading.
|
|
|
|
|
Code To Upload Image
//check whether FileUpload control has file or not
if (FileUpload1.HasFile)
{
string fileExtension = Path.GetExtension(FileUpload1.FileName);
if (fileExtension.ToLower() != ".jpg" && fileExtension.ToLower() != ".jpeg")
{
lblMessage.Text = "Only File With .jpg and .jpeg Extension are allowed";
lblMessage.ForeColor = System.Drawing.Color.Red;
}
else
{
if (File.Exists(Server.MapPath("~/Uploaded_Image/" + FileUpload1.FileName)))
{
lblMessage.Text = "Image Already Exist...Please Select Another Image";
lblMessage.ForeColor = System.Drawing.Color.Blue;
return;
}
else
{
FileUpload1.SaveAs(Server.MapPath("~/Uploaded_Image/" + FileUpload1.FileName));
lblMessage.Text = "File Uploaded Successfully";
lblMessage.ForeColor = System.Drawing.Color.Green;
}
}
}
else
{
lblMessage.Text = "Please Select File to be uploaded";
lblMessage.ForeColor = System.Drawing.Color.Red;
}
|
|
|
|
|
Hi everybody!!
I'm starting with asp.net and i would like to try my code online.. can you advise me some free hosting for asp.net with the possibility to use sql server?
Thanks
|
|
|
|
|
|
|
Hi,
In asp.net hosting using web services.
web services support IIS hosting only,
wcf supports IIS, WAS, SELF HOSTING
In asp.net a free hosting is possible
|
|
|
|
|
All programmers I m requesting please tell me how can i build my own online backup site using asp . net
http://www.codeproject.com/script/Forums/Images/coffee.gif
VICKY_ARYAN
|
|
|
|
|
|
Greetings All
I'm experiencing some difficulty setting up Memberships using the WSAT. I get the following error:
"There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.
The following message may help in diagnosing the problem: Unable to connect to SQL Server database."
I've already tried running aspnet_regsql (which was successful) and I'm checking for solutions in Google, but so far nothing has helped. I've also tried changing the permissions on the MSSQL directory and checking my firewalls; not to mention using the SQL Server Configuration manager to make sure the named pipes are enabled (and restarting the service). I also tried running through the suggestion in this article:
http://weblogs.asp.net/sukumarraju/archive/2010/01/17/configuring-web-application-to-utilise-asp-net-application-services-database.aspx
but it only made matters worse.
I'm sure there's something simple I'm overlooking. Does anyone have any suggestions about what else I might try?
=======================
Every experience in life is a lesson to be learned
A. Stevens
B.S., Computer Science
|
|
|
|
|
You'll need to try to diagnose where the connection is failing:
- Can you connect to the server specified in your connection string using sqlcmd[^]?
- Can you connect using the credentials specified in your connection string?
- Can you access the database specified in your connection string?
- Can you access the database using the credentials from your connection string?
If the answer to all of those questions is "Yes", please post the connectionStrings and system.web/roleManager sections from your web.config file. Don't forget to remove any passwords before posting!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Richard. The answer is yes to some of these, but I want to try one more thing. If it doesn't work I will indeed post the connectionStrings and <rolemanager> information.
=======================
Every experience in life is a lesson to be learned
A. Stevens
B.S., Computer Science
|
|
|
|
|
OK. I'm fairly certain that I can connect to the database, using ADO.NET (i.e. - using SqlConnection and SqlCommand classes). I also took a look at the database I created and lo and behold under the Stored Procedure I saw all the Membership sp's that are created when using the WSAT, such as "Membership_ChangePassword" and "Membership_CreateUser". So I'm confused about why I'm seeing the error (see my original post). I'm including the connectionStrings and <rolmanager> info as requested:
The ConnectionString is:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
<add name="StarfleetAcademyDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=StarfleetAcademyDB;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
and the <rolemanager> tag is:
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>
Does it matter that there are two entries for the name attribute even though the values are different? Any help you can offer would be greatly appreciated.
=======================
Every experience in life is a lesson to be learned
A. Stevens
B.S., Computer Science
|
|
|
|
|
DRAYKKO wrote: It can also be caused by the role manager feature not being enabled.
DRAYKKO wrote: <roleManager enabled="false">
A slight clue here, perhaps?
Assuming your membership stored procedures are in the StarfleetAcademyDB database, I would expect to see:
<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">
<providers>
<clear />
<add
name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="StarfleetAcademyDBConnectionString"
applicationName="/"
/>
</providers>
</roleManager>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for your feedback Richard. I tried the changes you suggested, but the error persists. I also tried rebooting (just in case), but I'm still getting the error about connecting to the database. I think it also bears mentioning that I've already tried uninstalling and re-installing SQL Server 2008, as well.
Andre
|
|
|
|
|
Hi,
Actually connect to the database properly means first you create the database that database name you will give in your in connection window(username, password and database name)
1. goto in visual studio.
2. server explorer
3. data connection after that right click and click add connection
4. select your server name means system name(automatically will come).
5. use sql server authentication(give ur uname and pass word must correctly)
6.select data base name.
7. test connection.
|
|
|
|
|
I'm using Windows authentication, but I will try it with a username and password. I am curious as to whether we can still use Windows authentication or not?
|
|
|
|
|
i need to run two different versions of CR in my system. i have tried copying the dll files in to the bin folder also changed the reference to the bin folder. what actually happened is i can run the old version (CR 10) by copying the rpt file developed in VS2005. But at that time i can't use the CR13. DLL hell issue is raised, Can any one suggest me a better solution for my current issue.
|
|
|
|
|
i have use master page in my project.
I have click the button get the query in sql server 2005 in display the result in Gridview. that how to loading image in my click button?
|
|
|
|
|
Hello again. For last three hours I try to create a "httpHandler". IIS 7.5, .NET 2.0, Integrated mode.
My web.config:
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="version" type="Handler"/>
</httpHandlers>
<compilation debug="true"/>
<httpRuntime/>
</system.web>
</configuration
I get an error 500:23 "The application defines configuration in system.web.httpHandlers, migrate it to system.webServer.
Of course I tried it but with no luck (configuration is invelid). Tried also moving entire config to system.webServer.
What have I been missing?
Greetings - Jacek
modified 17-Sep-13 9:37am.
|
|
|
|
|
how to manually populate my below model from mvc action method. please help with code. thanks
namespace MvcPractise.Models
{
public class Student
{
[Required(ErrorMessage = "First Name Required")]
[Display(Name = "First Name :")]
[StringLength(5, ErrorMessage = "First Name cannot be longer than 5 characters.")]
public string FirstName { get; set; }
[Required(ErrorMessage = "Last Name Required")]
[Display(Name = "Last Name :")]
[StringLength(5, ErrorMessage = "Last Name cannot be longer than 5 characters.")]
public string LastName { get; set; }
[Required(ErrorMessage = "DOB require")]
[Display(Name = "DOB :")]
[DataType(DataType.Date)]
public DateTime Dob { get; set; }
[Required(ErrorMessage = "State Required")]
[Display(Name = "State :")]
public List<State> State { get; set; }
[Required(ErrorMessage = "City Required")]
[Display(Name = "City :")]
public List<City> City { get; set; }
[Required(ErrorMessage = "Language known Required")]
[Display(Name = "Language known :")]
public List<Language> Language { get; set; }
[Required(ErrorMessage = "Sex Required")]
[Display(Name = "Sex :")]
public List<Sex> Sex { get; set; }
[Required(ErrorMessage = "Computer Course Required")]
[Display(Name = "Computer Course Done :")]
public List<ComputerCourse> ComputerCourse { get; set; }
}
public class State
{
public string ID { get; set; }
public string Name { get; set; }
}
public class City
{
public string ID { get; set; }
public string Name { get; set; }
}
public class Language
{
public string ID { get; set; }
public string Name { get; set; }
}
public class Sex
{
public string ID { get; set; }
public string Type { get; set; }
}
public class ComputerCourse
{
public string ID { get; set; }
public string Type { get; set; }
}
}
tbhattacharjee
|
|
|
|
|
create an object of this model and assign values as required inside the action method.
More information please.
|
|
|
|