Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts

Monday, March 26, 2012

The Controls collection cannot be modified because the control contains code blocks (i.e.

Hi,

I'm trying to dynamically set the src of an iframe with the <% %> block:
<iframe id="content" src="http://pics.10026.com/?src=<% = Request.QueryString.Get("content") %>"
width="100%"></iframe
Notice that the tag (intentionally) has no runat=server and also nested in a
<TD> tag...

What am I doing wrong?

Thanks,
HadarHadar,

Looks like you have a balagan with quotes. Try this:
src=<% = String.Format ("'{0}'", Request.QueryString.Get("content") %
Eliyahu

"Hadar" <crazy5@dotnet.itags.org.bezeqint.net> wrote in message
news:uB23lzJlEHA.208@dotnet.itags.org.TK2MSFTNGP12.phx.gbl...
> Hi,
> I'm trying to dynamically set the src of an iframe with the <% %> block:
> <iframe id="content" src="http://pics.10026.com/?src=<% = Request.QueryString.Get("content") %>"
> width="100%"></iframe>
> Notice that the tag (intentionally) has no runat=server and also nested in
a
> <TD> tag...
> What am I doing wrong?
> Thanks,
> Hadar
One more bracket:

src=<% = String.Format ("'{0}'", Request.QueryString.Get("content")) %
--
Eliyahu

"Eliyahu Goldin" <removemeegoldin@dotnet.itags.org.monarchmed.com> wrote in message
news:exsYv2KlEHA.3372@dotnet.itags.org.TK2MSFTNGP09.phx.gbl...
> Hadar,
> Looks like you have a balagan with quotes. Try this:
> src=<% = String.Format ("'{0}'", Request.QueryString.Get("content") %>
> Eliyahu
> "Hadar" <crazy5@dotnet.itags.org.bezeqint.net> wrote in message
> news:uB23lzJlEHA.208@dotnet.itags.org.TK2MSFTNGP12.phx.gbl...
> > Hi,
> > I'm trying to dynamically set the src of an iframe with the <% %> block:
> > <iframe id="content" src="http://pics.10026.com/?src=<% = Request.QueryString.Get("content") %>"
> > width="100%"></iframe>
> > Notice that the tag (intentionally) has no runat=server and also nested
in
> a
> > <TD> tag...
> > What am I doing wrong?
> > Thanks,
> > Hadar
Hi Eliyahu,

Thanks for your reply.
I tried what you suggested, and still it doesn't work (same error).
I guess it's not the quotes...

Any other suggestions?

Hadar

> One more bracket:
> src=<% = String.Format ("'{0}'", Request.QueryString.Get("content")) %>
> --
> Eliyahu
> "Eliyahu Goldin" <removemeegoldin@dotnet.itags.org.monarchmed.com> wrote in message
> news:exsYv2KlEHA.3372@dotnet.itags.org.TK2MSFTNGP09.phx.gbl...
> > Hadar,
> > Looks like you have a balagan with quotes. Try this:
> > src=<% = String.Format ("'{0}'", Request.QueryString.Get("content") %>
> > Eliyahu
> > "Hadar" <crazy5@dotnet.itags.org.bezeqint.net> wrote in message
> > news:uB23lzJlEHA.208@dotnet.itags.org.TK2MSFTNGP12.phx.gbl...
> > > Hi,
> > > > I'm trying to dynamically set the src of an iframe with the <% %>
block:
> > > <iframe id="content" src="http://pics.10026.com/?src=<% = Request.QueryString.Get("content")
%>"
> > > width="100%"></iframe>
> > > > Notice that the tag (intentionally) has no runat=server and also
nested
> in
> > a
> > > <TD> tag...
> > > > What am I doing wrong?
> > > > Thanks,
> > > Hadar
> >

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;}