Monday, March 26, 2012
The Controls (buttons) Are Not Displayed In Asp.net, after i ran the asp.net pro
i have created one new asp.net web application project (with visual basic enabled not C#).
i have used two "lables" and two "textboxes". after creating that webform. i ran that asp.net project.
but it did not show the form as what i have seen before ran.
it shows onle tow lables and it did not show the textbox controls. that too lables are shown top left cornor one by one. but i have used lables at center of the form.
i have attached two jpg files. first one is before run. second one for after run.
how to solve this problem.Can you post your code?
Run aspnet_regiis -c in the Visual Studio command prompt.
hi mendhak
how to enter visula studio command prompt. i am newbie to vb.net / asp.net
Start > Programs > Microsoft VIsual Studio > Visual Studio Tools > Visual Studio Command Prompt
hi mendhak
i tried this.
now i am seeing the error message "server application unavailable" in ie after exectuing my asp.net webapplication project.
but i am able to open iis server default pager when typing "http://localhost" in ie
how to solve that problem
Did you reset IIS after running aspnet_regiis?
Tuesday, March 13, 2012
The image cannot be displayed, because it contains errors.
I have a code in photo.aspx.cs as follows to display image in browser (photo.aspx does not have any space or markup, only @dotnet.itags.org. Page directive):
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "image/bmp";
string employeeID = Request.QueryString["EmployeeID"];
string sqlText = "SELECT Photo FROM Employees WHERE EmployeeID = " + employeeID;
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ToString());
SqlCommand command = new SqlCommand(sqlText, connection);
connection.Open();
SqlDataReader dr = command.ExecuteReader();
if (dr.Read())
{
Response.BinaryWrite((byte[])dr["Photo"]);
}
connection.Close();
Response.Flush();
Response.Close();
}
Now when I access this page as http://localhost:4538/WebSite12/photo.aspx?EmployeeID=1 in firefox, it gives following error. Can someone help me to sort out this problem please?
The image "http://localhost:4538/WebSite12/photo.aspx?EmployeeID=1" cannot be displayed, because it contains errors.
Hi,
How about this one, which is from http://davidhayden.com/blog/dave/archive/2006/07/25/SavingDisplayingPhotosInSQLServerUsingASPNET.aspx
protectedvoid Page_Init(object sender, EventArgs e){if (Request.QueryString["id"]!=null) {int id;if (Int32.TryParse(Request.QueryString["id"],out id)) { Response.Clear(); Response.ContentType="image/jpeg"; Image image= RetrieveImage(id); image.Save(Response.OutputStream, ImageFormat.Jpeg); } }}private Image RetrieveImage(int photoId){ Image image=null;using (SqlConnection connection=new SqlConnection("...")) {using (SqlCommand command= connection.CreateCommand()) { command.CommandText="SELECT Photo FROM Photos
WHERE PhotoId = @.PhotoId"; command.Parameters.AddWithValue("@.PhotoId", photoId); connection.Open();byte[] imageData= (byte[])command.ExecuteScalar(); MemoryStream memStream=new MemoryStream(imageData); image= Image.FromStream(memStream); } }return image;}