How to get value from textbox in Jquery modal box
<p>I m using a user control on my page, I am opening this user control in a jquery modal popup window.
I want to perform some action on button click using jquery but when I try to check the value of my textbox I m getting blank value</p>

<p>Here is the code I am using</p>

<pre><code> &lt;asp:TextBox runat="server" ID="txtName" &gt;&lt;/asp:TextBox&gt;
</code></pre>

<p>I am trying to alert the value</p>

<pre><code>alert($('#ContentPlaceHolder1_User_txtName').val());

&lt;input id="ContentPlaceHolder1_User_txtName" type="text" name="ctl00$ContentPlaceHolder1$User$txtName"&gt;
</code></pre>

<p>Jquery used 1.5</p>

<p>I have tried using </p>

<pre><code>    $("#&lt;%=txtName.ClientID%&gt;")
    $('#ContentPlaceHolder1_User_txtName').val(); 
    $("#txtName").text();
    $("#ContentPlaceHolder1_User_txtName").text(); 
</code></pre>

<p>Every time I am getting "" value
Please tell me where I m making mistake</p>

<blockquote>
  <p>(function($) {
      $.modal = function(config) {</p>
</blockquote>

<pre><code>    var defaults, options, modal, header, content, footer, close, overlay, width, centerOffset;

    defaults = {            
        title: ''
        , byline: ''

        , ajax: ''
        , div: ''   

        , slide: false  
        , slideEl: '.slide' 

        , btnClass: 'btn small secondary'

        , overlay: true
        , overlayClose: true

        , beforeOpen: function () {}
        , afterOpen: function () {}

        , debug: false
    };

    options = $.extend(defaults, config);       

    $.modal.forceClose ();

    modal = $('&lt;div&gt;', { 'id' : 'modal' });     
    header = $('&lt;div&gt;', { 'id' : 'modal_header' });     
    content = $('&lt;div&gt;', { 'id' : 'modal_content' });           
    overlay = $('&lt;div&gt;', { 'id' : 'modal_overlay'   });     
    close = $('&lt;div&gt;', { 'id' : 'modal_close' , 'html': 'x' });

    header.appendTo (modal);
    content.appendTo (modal);
    close.appendTo (modal);

    options.beforeOpen (modal);

    modal.appendTo ('body').hide ().fadeIn (500);

    if (options.overlay) {
        overlay.appendTo ('body');
    }

    if (options.overlayClose) {
        overlay.bind ('click', function (e) { $.modal.close (); });
    }

    close.bind ('click', function (e) { $.modal.close (); });       

    (options.title !== '') ? header.append ('&lt;h3&gt;' + options.title + '&lt;/h3&gt;') : '';             
    (options.byline !== '') ? header.append ('&lt;div class="byline"&gt;' + options.byline + '&lt;/div&gt;') : '';  

    if (options.ajax !== '') {
        content.html ('&lt;div id="modal_loader"&gt;&lt;img src="../images/mba/ajax-loader.gif" /&gt;&lt;/div&gt;');
        $.modal.reposition ();
        $.get (options.ajax, function (response) {
            content.html (response);
            handleContent ();
        });
    }                       

    if (options.div !== '') {
        content.html ($(options.div).html());
        handleContent ();
    }   

    function handleContent () {
        $.modal.reposition ();      
        if (options.slide) { handleSlides (); }     

        setTimeout (function () {   
            options.afterOpen (modal);
        }, 1000);
    }   

    function handleSlides () {
        var slides = modal.find (options.slideEl);              
        slides.hide ().eq (0).show ().addClass ('current_slide');           
        var footer = $('&lt;div&gt;', { id: 'modal_footer' }).appendTo (modal);           
        var prev = $('&lt;button&gt;', { id: 'prev', html: '&lt;u&gt;P&lt;/u&gt;revious' }).addClass (options.btnClass).appendTo (footer);
        var display = $('&lt;span&gt;', { id: 'display' }).appendTo (footer);
        var next = $('&lt;button&gt;', { id: 'next', html: '&lt;u&gt;N&lt;/u&gt;ext' }).addClass (options.btnClass).appendTo (footer);            
        display.html ('&lt;span class="current_page"&gt;1&lt;/span&gt; of ' + slides.length);
        prev.attr ('disabled', 'disabled'); 

        $(document).bind ('keyup.modal', function (e) {
            if (e.keyCode == 78 || e.keyCode == 39) { navigateSlides ('forward', slides); }
            if (e.keyCode == 80 || e.keyCode == 37) { navigateSlides ('backward', slides); }
        });

        footer.find ('button').bind ('click', function (e) {
            var direction = ($(this).is ('#next')) ? 'forward' : 'backward';
            navigateSlides (direction, slides);
        });

    }

    function navigateSlides (direction, slides) {
        var currentSlide, nextSlide, next, prev;
        next = $('#next');
        prev = $('#prev');
        currentSlide = content.find ('.current_slide');                 
        nextSlide = (direction == 'forward') ? currentSlide.next (options.slideEl) : currentSlide.prev (options.slideEl);           

        if (nextSlide.length &gt; 0) {
            nextSlide.addClass ('current_slide').show ().siblings (options.slideEl).hide ().removeClass ('current_slide');
            $('#display .current_page').text (nextSlide.index () + 1);

            (nextSlide.index () === 0) ? prev.attr ('disabled', 'disabled') : prev.removeAttr ('disabled');
            (nextSlide.index () === slides.length - 1) ? next.attr ('disabled', 'disabled') : next.removeAttr ('disabled');     

            var contentWidth = nextSlide.outerWidth ();                 
            content.width (contentWidth + 30);
            //$.modal.reposition ();    
        }                           
    }

    $(document).bind ('keyup.modal', function (e) { 
        if (e.keyCode == 27) { $.modal.close (); }          
    });     

};

$.modal.reposition = function () {
    var width = $('#modal').outerWidth ();      
    var centerOffset = width / 2;   
    var pageScroll = getPageScroll ();  
    $('#modal').css ({ 'left': '50%', 'top': pageScroll[1] + 100, 'margin-left': '-' + centerOffset + 'px' });
};

$.modal.close = function () {
    $('#modal').fadeOut ('medium', function () { $(this).remove (); });
    $('#modal_overlay').fadeOut ('medium', function () { $(this).remove (); });
    $(document).unbind ('keyup.modal');
};

$.modal.forceClose = function () {
    $('#modal').remove ();
    $('#modal_overlay').remove ();
    $(document).unbind ('keyup.modal');
};

$.modal.setTitle = function (title) {
    var h3 = $('#modal_header').find ('h3');        
    if (h3.length &gt; 0) {
        h3.html (title);
    } else {
        $('&lt;h3&gt;', { html: title }).prependTo ('#modal_header'); 
    }
};

$.modal.setByline = function (text) {
    var el = $('#modal_header').find ('.byline');       
    if (el.length &gt; 0) {
        el.html (text);
    } else {
        $('&lt;div&gt;', { 'class': 'byline', html: text }).appendTo ('#modal_header');   
    }
};

// getPageScroll() by quirksmode.com
    function getPageScroll() {
        var xScroll, yScroll;
        if (self.pageYOffset) {
          yScroll = self.pageYOffset;
          xScroll = self.pageXOffset;
        } else if (document.documentElement &amp;&amp; document.documentElement.scrollTop) {     // Explorer 6 Strict
          yScroll = document.documentElement.scrollTop;
          xScroll = document.documentElement.scrollLeft;
        } else if (document.body) {// all other Explorers
          yScroll = document.body.scrollTop;
          xScroll = document.body.scrollLeft;
        }
        return new Array(xScroll,yScroll);
      }
</code></pre>

<p>})(jQuery);</p>
