C#´úÂëÓëjavaScriptº¯ÊýµÄÏ໥µ÷ÓÃ
C#´úÂëÓëjavaScriptº¯ÊýµÄÏ໥µ÷ÓÃ
ÎÊ£º
1.ÈçºÎÔÚJavaScript·ÃÎÊC#º¯Êý?
2.ÈçºÎÔÚJavaScript·ÃÎÊC#±äÁ¿?
3.ÈçºÎÔÚC#ÖзÃÎÊJavaScriptµÄÒÑÓбäÁ¿?
4.ÈçºÎÔÚC#ÖзÃÎÊJavaScriptº¯Êý?
ÎÊÌâ1´ð°¸ÈçÏ£º
javaScriptº¯ÊýÖÐÖ´ÐÐC#´úÂëÖеĺ¯Êý£º
·½·¨Ò»£º1¡¢Ê×ÏȽ¨Á¢Ò»¸ö°´Å¥£¬ÔÚºǫ́½«µ÷Óûò´¦ÀíµÄÄÚÈÝдÈëbutton_clickÖÐ;
2¡¢ÔÚǰ̨дһ¸öjsº¯Êý£¬ÄÚÈÝΪdocument.getElementById("btn1").click();
3¡¢ÔÚǰ̨»òºǫ́µ÷ÓÃjsº¯Êý£¬¼¤·¢clickʼþ£¬µÈÓÚ·ÃÎʺǫ́c#º¯Êý£»
·½·¨¶þ£º1¡¢º¯ÊýÉùÃ÷Ϊpublic
ºǫ́´úÂë(°Ñpublic¸Ä³ÉprotectedÒ²¿ÉÒÔ)
public string ss()
{
return("a");
}
2¡¢ÔÚhtmlÀïÓã¼%=fucntion()%£¾¿ÉÒÔµ÷ÓÃ
ǰ̨½Å±¾
£¼script language=javascript£¾
var a = "£¼%=ss()%£¾";
alert(a);
£¼/script£¾
·½·¨Èý£º1¡¢£¼script language="javascript"£¾
£¼!--
function __doPostBack(eventTarget, eventArgument)
{
var theForm = document.Form1; //Ö¸runat=serverµÄform
theForm.__EVENTTARGET.value = eventTarget;
thefrom.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
--£¾
£¼/script£¾
£¼input id="Button1" type="button" name="Button1" value="°´Å¥" onclick="javascript:__doPostBack('Button1','')"£¾
·½·¨ËÄ£º£¼script language="javascript"£¾
function SubmitKeyClick()
{
if (event.keyCode == 13)
{
event.cancelBubble = true;
event.returnValue = false;
document.all.FunName.value="ÄãÒªµ÷Óõĺ¯ÊýÃû"£»
document.form[0].submit();
}
}
£¼/script£¾
£¼INPUT onkeypress="SubmitKeyClick()" id="aaa" type="text"£¾
£¼input type="hidden" name="FunName"£¾ ¡´£¡--ÓÃÀ´´æ´¢ÄãÒªµ÷Óõĺ¯Êý --¡µ
ÔÚ.CSÀïÓУº
public Page_OnLoad()
{
if (!Page.IsPost())
{
string strFunName=Request.Form["FunName"]!=null?Request.Form["FunName"]:"";
//¸ù¾Ý´«»ØÀ´µÄÖµ¾ö¶¨µ÷ÓÃÄĸöº¯Êý
switch(strFunName)
{
case "enter()":
enter() ; //µ÷Óøú¯Êý
break;
case "ÆäËû":
//µ÷ÓÃÆäËûº¯Êý
break;
default:
//µ÷ÓÃĬÈϺ¯Êý
break;
}
}
}
public void enter()
{
//……±ÈÈç¼ÆËãijֵ
}
ÎÊÌâ2.ÈçºÎÔÚJavaScript·ÃÎÊC#±äÁ¿?
´ð°¸ÈçÏ£º
·½·¨Ò»£º1¡¢Í¨¹ýÒ³ÃæÉÏÒþ²ØÓò·ÃÎÊ£¼input id="xx" type="hidden" runat="server"£¾
·
Ïà¹ØÎĵµ£º
ʵÏÖ¿¨Ò³Ê½webµÄjs£º
function ShowContent(id,num){
for(i=1;i<=num;i++){
document.getElementById("page_"+i).className="";
document.getElementById("content_"+i).style.display="none";
}
document.getElementById("content_"+id).style.display="block";
......
Ò»¡¢ºǫ́£¨.csÎļþ£©·½·¨£º
public string GetString(string name)
{
return ("Hello " + name);
}
&n ......
ÒÑÖªÓÐÒ»¸öXMLÎļþ£¨bookstore.xml£©ÈçÏ£º
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
<price>5.95</price& ......
//ͳ¼Æ×Ö·û´®ÖÐÌض¨×Ö·û´®µÄ¸öÊý
function getStrCount(scrstr,armstr)
{ //scrstr Ô´×Ö·û´® armstr ÌØÊâ×Ö·û
var count=0;
while(scrstr.indexOf(armstr) >=1 )
{
scrstr = scrstr.replace(armstr,"")
count++;
}
re ......
response.write "<script language='javascript'>"
response.write "alert('Óû§Ãû»òÃÜÂë´íÎó!');"
response.write "hist ......