gpt4 book ai didi

c# - 我如何从 C# 调用 javascript

转载 作者:行者123 更新时间:2023-12-02 20:16:40 26 4
gpt4 key购买 nike

我想在网站上使用带有产品界面的 jQuery 价格范围 slider ,我找到了一些示例,但他们添加了 php,如何使用 c# 调用此 javascript?

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link type="text/css" href="jquery-ui-1.8rc1.custom.css" rel="stylesheet" />

<script type="text/javascript" src="js/jquery-1.4.1.min.js"></script>

<script type="text/javascript" src="js/jquery-ui-1.8rc1.custom.min.js"></script>

<script type="text/javascript">

$(function() {

$slider = $("#slider");//Caching slider object

$amount = $("#amount");//Caching amount object

$slider.slider({

range: true, // necessary for creating a range slider

min: 0, // minimum range of slider

max: 500, //maximimum range of slider

values: [75, 300], //initial range of slider

slide: function(event, ui) { // This event is triggered on every mouse move during slide.

$amount.html('$' + ui.values[0] + ' - $' + ui.values[1]);//set value of amount span to current slider values

}

});



$amount.html('$' + $slider.slider("values", 0) + ' - $' + $slider.slider("values", 1));

});

</script>

<title></title>

<style type="text/css">

body{font-size: 12px;font-family:"Arial","Helvetica","Verdana","sans-serif";}

.left{float:left;}

.clear{clear:both}

#wrapper{margin:40px auto;width:940px}

#leftSlider{width: 200px;margin-right: 30px;}

#range{margin-bottom: 20px;}

#products{width:710px}

#products ul{

list-style: none;

margin:0px;padding:0px

}

#products ul li{

margin:4px;

float:left;

height:180px;

width:200px;

background-color: #333;

-moz-border-radius:6px;

-webkit-border-radius:6px;

-khtml-border-radius:6px;

}

#amount{font-size: 14px; text-shadow:0px 1px 0px #ccc}

</style>

</head>



<body>

<div id="wrapper">

<div class="left" id="leftSlider">

<div id="range">Price Range <span id="amount"></span></div>

<div id="slider"></div>

</div>

<div class="left" id="products">

<ul>

<li></li>

<li></li>

<li></li>

<li></li>

<li></li>

<li></li>

<li></li>

<li></li>

<li></li>

</ul>

</div>

</div>



</body>

</html>

最佳答案

来自MSDN docs

public static void RegisterStartupScript(
Control control,
Type type,
string key,
string script,
bool addScriptTags
)

参数

control Type: System.Web.UI.Control The control that is registering the client script block.

type Type: System.Type The type of the client script block. This parameter is usually specified by using the typeof operator (C#) or the GetType operator (Visual Basic) to retrieve the type of the control that is registering the script.

key Type: System.String A unique identifier for the script block.

script Type: System.String The script.

addScriptTags Type: System.Boolean true to enclose the script block with and tags; otherwise, false.

这将在客户端生成一个脚本 block 。

关于c# - 我如何从 C# 调用 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6188244/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com