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"£¾
·
Ïà¹ØÎĵµ£º
Ò»¡¢Ê²Ã´ÊDZհü£¿
“¹Ù·½”µÄ½âÊÍÊÇ£ºËùν“±Õ°ü”£¬Ö¸µÄÊÇÒ»¸öÓµÓÐÐí¶à±äÁ¿ºÍ°ó¶¨ÁËÕâЩ±äÁ¿µÄ»·¾³µÄ±í´ïʽ£¨Í¨³£ÊÇÒ»¸öº¯Êý£©£¬Òò¶øÕâЩ±äÁ¿Ò²ÊǸñí´ïʽµÄÒ»²¿·Ö¡£
ÏàÐźÜÉÙÓÐÈËÄÜÖ±½Ó¿´¶®Õâ¾ä»°£¬ÒòΪËûÃèÊöµÄ̫ѧÊõ¡£ÎÒÏëÓÃÈçºÎÔÚJavascriptÖд´½¨Ò»¸ö±Õ°üÀ´¸æËßÄãʲôÊDZհü£¬ÒòΪÌø¹ý±Õ°üµÄ´´ ......
ÉîÈëÀí½âJavaScriptµÄ±äÁ¿×÷ÓÃÓò
http://www.cnblogs.com/rainman/archive/2009/04/28/1445687.html
ÔÚѧϰJavaScriptµÄ±äÁ¿×÷ÓÃÓò֮ǰ£¬ÎÒÃÇÓ¦µ±Ã÷È·¼¸µã£º
a¡¢JavaScriptµÄ±äÁ¿×÷ÓÃÓòÊÇ»ùÓÚÆäÌØÓеÄ×÷ÓÃÓòÁ´µÄ¡£
b¡¢JavaScriptûÓп鼶×÷ÓÃÓò¡£
c¡¢º¯ÊýÖÐÉùÃ÷µÄ±äÁ¿ÔÚÕû¸öº¯ÊýÖж¼Óж¨Òå¡£
1¡¢JavaScriptµÄ×÷ÓÃÓòÁ´ ......
Ò»¡¢ºǫ́£¨.csÎļþ£©·½·¨£º
public string GetString(string name)
{
return ("Hello " + name);
}
&n ......
JavaScriptʼþ·ÖÀࣺ
1¡¢²¶»ñÐÍ£¨IE²»Ö§³Ö£©£¨´ÓDOM½á¹¹µÄ×¶Ë¿ªÊ¼ÏòÏÂÑÓÉ죩
2¡¢Ã°ÅÝÐÍ£¨´ÓDOM½á¹¹µÄ×îµÍ¶ËÏòÉÏÒ»¼¶¼¶ÑÓÉ죩
¡¾IE7ÒÔÉÏ¿ÉÒÔ¸ø‘html’Ìí¼Óonclickʼþ£¬IEÖÐbody->html£¬»ðºüÖÐhtml->body¡¿
JavaScriptÌí¼Óʼþ¼àÌý£º
1¡¢IE£º
[object].attachEvent("event_handler", fnHandler); ......
´Ë½Ì³ÌÏòÄãÌṩ ASP.NET MVC ÊÓͼ¼ò½é, ÊÓͼÊý¾Ý, ºÍ HTML Helpers¡£½Ì³Ì×îºó£¬ÄãÓ¦¸Ã»áÀí½âÈçºÎ´´½¨ÐÂÊÓͼ£¬´Ó¿ØÖÆÆ÷´«µÝÊý¾Ýµ½ÊÓͼ£¬ºÍʹÓà use HTML Helpers ÔÚÊÓͼÖÐÉú³ÉÄÚÈÝ¡£
Àí½âÊÓͼ
²»Ïñ ASP.NET »òÕßASP, ASP.NET MVC ²¢²»°üÀ¨ÈκÎÖ±½Ó¶ÔÓ¦Ò³ÃæµÄ¶«Î÷¡£ ÔÚ ASP.NET MVC Ó¦ÓóÌÐòÖУ¬Ó²ÅÌÉϲ¢²»´ ......