日期:2014-05-18  浏览次数:20434 次

如何在html里面的js中写一个后台一样的代码呢?
如题

------解决方案--------------------
是不时在JS里写后台代码阿? 加 <%= %> 就好了
------解决方案--------------------
js中写一个后台一样的代码
是什么意思,lz能说的明白一点吗?
------解决方案--------------------
<% @ Import namespace= "System.Diagnostics " %>

<script language= "C# " runat= "Server " debug= "true ">

void Page_Load(Object Sender, EventArgs e){

btnKill.Attributes.Add( "onclick ", "javascript: return confirm( '你真的要杀死这个进程吗? '); ");

}

private void KillProcess(string processName){

System.Diagnostics.Process myproc= new System.Diagnostics.Process();

//得到所有打开的进程

try{

foreach (Process thisproc in Process.GetProcessesByName(processName)) {

if(!thisproc.CloseMainWindow()){

thisproc.Kill();

}

}

}

catch(Exception Exc)

{

msg.Text+= "杀死 " +procname.SelectedItem.Text + "失败! ";

}

}

public void btnKill_Click(object sender, System.EventArgs e)

{

KillProcess(procname.SelectedItem.Text);

msg.Text= procname.SelectedItem.Text + " 已经被杀死。 ";

}

public void btnShow_Click(object sender, System.EventArgs e){

ArrayList procList =new ArrayList();

string tempName= " ";

int begpos;

int endpos;

foreach (Process thisProc in System.Diagnostics.Process.GetProcesses()) {

tempName=thisProc.ToString();

begpos = tempName.IndexOf( "( ")+1;

endpos= tempName.IndexOf( ") ");

tempName=tempName.Substring(begpos,endpos-begpos);

procList.Add(tempName);

}

procname.DataSource=procList;

procname.DataBind();

}

</script>
你可以模仿这个试一下
------解决方案--------------------
同意楼上