embedding a webpage

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?
 
E

Eric Lawrence [MSFT]

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.
 
J

Joe Bonavita

yes, I tried changing the .SRC property also but the image doesn't change.
Is RegisterStartupScript not the right way to do this?
 
E

Eric Lawrence [MSFT]

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.
 
J

Joe Bonavita

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.
 
E

Eric Lawrence [MSFT]

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top