tags:

views:

16

answers:

1

Hi

I'm filling some labels using jQuery AJAX and it's working properly (i'm getting the values through webservices). But after that, i'm firing and Button click to get that values but in debugging the labels are empty.

I think it's because the values are losing in PostBack.

Is there anyway to keep those labels values on Postback?

+2  A: 

Since the labels are just text in the HTML, there is no data being sent back in the Post that tells ASP.NET that the labels have changed.

You may need to include a Hidden field to track the text of the labels.

That being said (and since you are already using jQuery), I would recommend using a call-back rather than a post-back for this particular scenario.

John Gietzen
Instead of calling the PostBack, i'm now trying to call another WebMethod (from a click in a input) and getting the values through jQuery too but all vars are going to the Webmethod with the value "undefined"Is this the properly way to get an value?var id = $("#ctl00_ContentDireita_LabelIdProduto option:text").val();
Guilherme Cardoso
If that is a dropdown, I think you want `option:selected`.
John Gietzen
No, it's an Label.
Guilherme Cardoso
Oh, then you would use `$("#ctl00_ContentDireita_LabelIdProduto").text()`
John Gietzen
I've replaced labels for spans and now i'm getting properly the values. Thanks for help mate ;)
Guilherme Cardoso