如何将jquery变量值获取到ASP.NET标签控件 [英] How to get the jquery variable value to ASP.NET label control

查看:50
本文介绍了如何将jquery变量值获取到ASP.NET标签控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将脚本变量(id1)转换为标签(lblcity)



脚本变量放在下面的脚本文件中,因为我正在存储城市名称城市名称绑定到标签



一旦检查我的代码并解决问题



提前谢谢你的家伙。 。



我尝试了什么:



i我这样试试< br $> b $ b

 <   ul     class   =  nav navbar-nav >  
<% - & nbsp;海德拉巴 - %>
< li class = > < ; a id < span class =code-keyword> = popupCity class = btn btn-sm data-toggle = modal data-target = #myModal href = > ; < img class = flag src = images / india_flag.jpg > & nbsp; < asp:标签 ID = lblcity runat = server > < / asp:Label > < span class = 仅限sr > (当前)< < span class =code-leadattribute> / span > < / a > < / li >
< / ul >





弹出代码:



 <   div     class   =  modal fade    id   =  myModal    tabindex   =   -  1   角色  = 对话框    aria-labelledby   =   myModalLabel >  
< div class = 模态对话框 role = document >
< div < span class =code-attribute> class = modal-content >
< div < span class =code-attribute> class = modal-body >
< div class = pops >

< img src = bkground / india_gate.jpg class = ind_gate img-responsive / >
< div class = choose_city style = position:absolute; margin-top:-42px;颜色:#fff; > < h2 > 选择您所在的城市< / h2 > < / div >
< div class = popb >
< div class = header > < h3 > < img class = flags src = images / india_flag.jpg > & nbsp; India < / h3 > < / div >
< hr / >
< div class = col-md-4 >
< p id = city1 > 海德拉巴< / p >
< p id = city2 > Bangolore < / p >
< p id = city3 > Chennai < / p >
< p id = < span class =code-keyword> city4 > 德里< / p >

< / div >
< / div >
< / div >
< span class =code-keyword>< / div >
< div class = modal-footer >
< 按钮 类型 = < span class =code-keyword> button class = btn btn-primary data-dismiss = modal > 关闭< / button >
< / div >
< / div >
< / div >
< / d iv >







脚本代码:



< script> 
$( function (){

var appendthis =( < div class ='modal-overlay js-modal-close'>< / div>);

$(' a [data-modal-id]')。click( function (e){
e.preventDefault();
$( body)。append(appendthis);
$( .modal-overlay)。fadeTo( 500 0 7 );
// $(。js-modalbox)。fadeIn(500);
var modalBox = $( this )。attr(' 数据模态-ID');
$(' #' + modalBox).fadeIn($()的数据());
});
document .getElementById( popupCity).innerHTML = localStorage.getItem( city
$(< span class =code-string>
p)。click( function ( ){
var cityName = $( this )。attr(' id');
var id1 = document .getElementById(cityName).innerHTML;
console .log(id1);
document .getElementById( popupCity) .innerHTML = id1;
// document.getElementById(lblcity)。innerHTML = id1;

localStorage.setItem( city,id1);
location .reload();
$( 。modal-box,.modal-overlay)。fadeOut(< span class =code-digit> 500
function (){
$( 。modal-overlay)。remove();
});
})
$( 。js-modal-close,.modal-overlay).click( function (){
$( .modal-box,.modal-overlay)。fadeOut( 500 function (){
$( .modal-overlay)。 remove();
});

});

$( window )。resize( function (){
$( 。modal-box)。css({
top:($ ( window )。height() - $( 。模态框)。outerHeight())/ 2
左:($( window )。width() - $( .modal-box)。outerWidth ())/ 2
});
});

$( window )。resize();

});
< / script>

解决方案

function ( ){

var appendthis =( < div class ='modal-overlay js-modal-close'>< / div>);


' a [data-modal-id]')。click( function (e){
e.preventDefault();


)追加(appendthis);

How to Get the script variable(id1) into label(lblcity)

script variable is placed in bellow script file in that i am storing City Name after that City name is bind into label

once check my code and solve the problem

Advance thanks guy's..

What I have tried:

i am trying this way

<ul class="nav navbar-nav">
							<%--&nbsp; Hyderabad--%>
							<li class=""><a id="popupCity" class="btn btn-sm" data-toggle="modal" data-target="#myModal" href="#"><img class="flag" src="images/india_flag.jpg">&nbsp;<asp:Label ID="lblcity" runat="server"></asp:Label> <span class="sr-only">(current)</span></a></li>
						</ul>



popup code:

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-body">
      <div class="pops"> 
	 
	  <img src="bkground/india_gate.jpg" class="ind_gate img-responsive" />
	 <div class="choose_city" style="position: absolute; margin-top: -42px; color:#fff;"><h2>Choose your city</h2></div>
      <div class="popb">
	  <div class="header"><h3><img class="flags" src="images/india_flag.jpg">&nbsp; India</h3></div>
	  <hr />
     <div class="col-md-4">
		<p id="city1">Hyderabad</p>
        <p id="city2">Bangolore</p>
        <p id="city3">Chennai</p>
        <p id="city4">Delhi</p>
									
		</div>
      </div>
      </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>




Script code :

<script>
$(function(){

var appendthis =  ("<div class='modal-overlay js-modal-close'></div>");

	$('a[data-modal-id]').click(function(e) {
		e.preventDefault();
    $("body").append(appendthis);
    $(".modal-overlay").fadeTo(500, 0.7);
    //$(".js-modalbox").fadeIn(500);
		var modalBox = $(this).attr('data-modal-id');
		$('#'+modalBox).fadeIn($(this).data());
	});  
	document.getElementById("popupCity").innerHTML = localStorage.getItem("city")
  $("p").click(function(){
    var cityName = $(this).attr('id');
    var id1 = document.getElementById(cityName).innerHTML;
    console.log(id1);
    document.getElementById("popupCity").innerHTML = id1;
    //document.getElementById("lblcity").innerHTML = id1;

    localStorage.setItem("city", id1);
    location.reload();
    $(".modal-box, .modal-overlay").fadeOut(500, function() {
        $(".modal-overlay").remove();
    });
  })
$(".js-modal-close, .modal-overlay").click(function() {
    $(".modal-box, .modal-overlay").fadeOut(500, function() {
        $(".modal-overlay").remove();
    });
 
});
 
$(window).resize(function() {
    $(".modal-box").css({
        top: ($(window).height() - $(".modal-box").outerHeight()) / 2,
        left: ($(window).width() - $(".modal-box").outerWidth()) / 2
    });
});
 
$(window).resize();
 
});
</script>

解决方案

(function(){ var appendthis = ("<div class='modal-overlay js-modal-close'></div>");


('a[data-modal-id]').click(function(e) { e.preventDefault();


("body").append(appendthis);


这篇关于如何将jquery变量值获取到ASP.NET标签控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆