-1
我想在剃刀中調用一個jquery函數,但我不能這樣做,爲什麼?jquery函數,在aspx剃鬚刀打電話
ClientScript.RegisterStartupScript(Page, GetType(), "success", "alert("");", true);
它說,它沒有定義...
我想在剃刀中調用一個jquery函數,但我不能這樣做,爲什麼?jquery函數,在aspx剃鬚刀打電話
ClientScript.RegisterStartupScript(Page, GetType(), "success", "alert("");", true);
它說,它沒有定義...
ClientScript.RegisterStartupScript()
是Web窗體。如果您想在Razor模板中調用JavaScript函數,請將該調用嵌入到模板中。
有很多不同的方法來實現這一點。在此示例中,視圖模型包含一個標誌,用於有條件地向客戶端輸出一段腳本。
@model MyModel
<div>
Some code in the view...doesn't matter
</div>
@if(MyModel.ShowSuccessAlert){
<script>
alert("Success!");
</script>
}
你不能剃刀它在服務器端和jQuery執行,在客戶端 – Jorge
的可能重複[調用剃鬚刀的子視圖裏面jQuery函數(http://stackoverflow.com/questions/17925439/call -jquery-function-inside-razors-subviews) –
是的,它可以從剃刀中調用。 – Severiano