How to get control value on home page using jQuery?

I have hidden field control in MasterPageand I want to get the value of hidden field control using jQuery on a page using MasterPage.

I have the following javascript that gets called if the hidden field on the page has a value:

if(!$('input[type=hidden]').val().length == 0 ) { } 

What kind of javascript will I need to check the value of the hidden field in MasterPagefrom the page?

+3
source share
3 answers

There is no difference between your page and the main page. Both of these concepts are at your ASP.NET level, and the browser simply receives one HTML document.

, , .

+3

, , , .

+3

The master page simply displays with the child page as one HTML code, so you just have to access it on the client side as usual.

Try rewriting this:

if(!$('input[type=hidden]').val().length == 0 ) { }

and

if ($('input[type=hidden]').val()) {}

which is a simpler condition if the hidden field matters. I'm not sure if !combined with ==does what you want it to perform logically. In any case, $('input[type=hidden]').val()a more readable IMO.

+2
source

All Articles