embedding a webpage

  • Thread starter Thread starter Joe Bonavita
  • Start date Start date
J

Joe Bonavita

I need to change images with the click of a button but I don't want the
entire page to refresh so I thought I should just use an embedded page.
I'm trying to use the <object> tag for this but can't figure out how to
change the page in the code behind.

I tried a javascript like this:
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script ");
sb.Append("language='javascript'>");
sb.Append("document.Form1.EmbedPic.data=\"MyPage.aspx?image=Image.jpg\";");
sb.Append("</script>");
RegisterStartupScript("PicPreview", sb.ToString());

but the page never changes. Is there something I'm doing wrong or is there a
better way to do this?
 
Have you considered using client-side JavaScript to change the .SRC property
of an Image tag?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
 
yes, I tried changing the .SRC property also but the image doesn't change.
Is RegisterStartupScript not the right way to do this?
 
Can you show me what your code looks like?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
 
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script ");
sb.Append("language='javascript'>");
sb.Append("document.frmHouse.Image1.SRC=\"bluehouse.jpg\";");
sb.Append("</script>");
RegisterStartupScript("PicPreview", sb.ToString());

This is being called from an ImageButton click event.

NOTE: the image is going to be differnent each time the button is clicked.
 
Can you send me the content of resultant the HTML page? I'd expect the
RegisterStartupScript call to put something in the Body OnLoad, so I'm not
sure how the button click fits into things. In classic HTML, you'd simply
add an OnClick event to the button tag that performed the .SRC change. In
ASP.NET, you'd want to have RUNAT=client, I'd expect...
 
Back
Top