How to get Control's property value at server side?

C

ca___t

Hi there:

I have a web image control and a web button in my aspx page.
Then I change its src property use by javascript at client side. But I
cann't get change value of image control when I click the button submit
this Form.
My question is how to get the value
This is my source

private void Page_Load(object sender, System.EventArgs e)
{
Image1.Attributes.Add("onclick", "appear();");
}

private void Button1_Click(object sender, System.EventArgs e)
{
string imageUrl = Image1.ImageUrl;
}

function appear()
{
var temp = window.document.getElementById("Image1");
temp.src = "image/cek_box_22.gif";
alert(temp.src);
}

Thanks a lot
jiangyh
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

There is no way of doing it, if you change the value in the client using
javascript you change the client part of the web control , the server side
( which is stored in the page in the __viewstate variable ) still hold the
old value, you need to keep the new value in some hidden field and check it
in the postback.


cheers,
 

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