script runat server 在ASP.NET中的用法
本文實例講述了中
的用法,分享給大家供大家參考。具體如下: 在的頁面中,可以在代碼標籤中通過添加代碼。其實,這裏的代碼和文件中的代碼地位是相同的',都是在服務器端執行的。 例: 複製代碼 代碼如下: void Select_Change(Object sender, EventArgs e) { e("Select Changed!"); }
可以看到,這裏同樣可以使用服務器端的e()來輸出內容。
需要注意的是,
中只能放置方法和屬性等,而不能直接添加語句和表達式。
另外,在頁面中,還可以使用<%>標記來引用服務器端的變量,或將服務器端的函數返回值顯示到客戶端。但是,這個標記的使用有一定的侷限性,其中不能聲明函數或子例程,只能放置語句。
在實際應用中,最好還是將前後臺代碼分開編寫,這樣不僅可以使代碼清晰明確,易於管理,也充分體現了與ASP 的區別。
希望本文所述對大家的程序設計有所幫助。
相關文章
-
公共英語二級寫作Preserving Natural Resources
Through the changes in the ways of making a living in a family over several generations, the cartoon aims at sounding a waing against mans wasteful use of natural resources and emphasizing the urgent -
A Letter to the University President爲題目的作文
Direction: For this part, you are allowed thirty minutes to write a composition on the topic: A letter to the university president about the canteen service on campus, you should write at least 100 words, -
MS SQL Server Management Studio Express安裝圖文具體步驟
Microsoft sql server Management Studio Express (SSMSE) 是一種免費、易用的圖形管理工具,用於管理 SQL Server 2005 Express Edition 和具有高級服務的 SQL Server 2005 Express Edition。SSMSE 還可以管理任何版本 -
C++中const-cast與reinterpret-cast運算符的用法
C++中const_cast與reinterpret_cast運算符的用法,經常被用於表達式中的類型轉換,下面是小編分享的運算符的用法,一起來看一下吧。 const_cast 運算符從類中移除 const、volatile 和 __unaligned 特性。 語法cons -
Thinkpad筆記本開機顯示Tointerrruptnormalstartup解決方法
Thinkpad筆記本開機顯示To interrrupt normal startup的解決方法1、先等待5-6分鐘,如果系統又恢復了正常,說明可能是系統硬盤或者風扇區出了問題;2、假如過了5-6分鐘依然沒有反應,則可嘗試先拆掉筆記本電池在裝上;3、或 -
以《The Surprise on Valentines Day》爲題的英語作文
Valentines Day is coming soon, it is on February14. The day is a big day for the couple, they need to spend the special day with romance, the boys are always buying gifts to their girls, the most comm -
JavaScript在Android的WebView中parseInt函數轉換不正確
今天被一個問題困擾,有一個頁面在瀏覽器(無論是手機還是PC)上運行良好,而通過WebView就出現了問題,有兩個值得計算始終出錯。於是就通過alert,把這個值顯示出來,發現和瀏覽器上計算的結果差了很多,本來是正數,卻變成了負數。仔 -
四級作文:Create a Conservation-Oriented Campus
四級作文:Create a Conservation-Oriented Campus,四級作文:Create a Conservation-Oriented Campus範文,免費提供給大家交流參考! Create a Conservation-Oriented Campus1.建設節約型校園十分重要2.原因是…&he -
Time To Stop Worrying About Invasive Species美文欣賞
Time To Stop Worrying About Invasive Species?You shouldn’t judge a book by its cover. And you shouldn’t judge a species by its place of origin. So say ecologists in a commentary in the joual Nature. -
A Letter to Univsity Pesident about the Canteen Service on C
dear president:i am a student who lives on campus and uses canteen services everyday. i would love to share my opinion on the services i received. also, i have some suggestions on how to improve the c