架构人生

通过HTML调用C# [架构]

先看一下HTML代码:

复制代码
<html>
  
<head>
    
<title>Demo for how to call C# business from html page</title>
    
<script src="http://www.zivosft.com/core/lib.js"></script>
  
</head>
  
<body>
    
<form id="default" action="Zivsoft.Business.DemoShow.AddSample">
        
<input id="a" type="text">+
        
<input id="b" type="text">+
        
<input id="c" type="text">=
        
<input id="txt" type='text'>
        
<input type="button" id="add" value="submit" onclick="CallBusiness();">
    
</form>
  
</body>
</html>
复制代码

再看一下HTML界面:

以上是一个非常简单的Demo,来演示通过HTML界面构造三个输入框,并调用后代C#逻辑Zivsoft.Business.DemoShow.AddSample实现三个数相加求和的功能。

 

下面看一下后台C#业务逻辑:

复制代码
namespace Zivsoft.Business.DemoShow
{
       public class AddSample:BaseControl
       {
              private void Add_Click(IComponent com)
              {
                 
this.txt.Value  System.Convert.ToInt32(this.tba.Value) 
                               + System.Convert.ToInt32(this.tbb.Value) 
                               + System.Convert.ToInt32(this.tbc.Value);
              }
       }
}
复制代码

最后看看一段JavaScript代码:

复制代码
        var url = http://www.zivsoft.com/cloudserver/default.aspx;
        req.open(
"POST", url, async);
        req.setRequestHeader(
"Content-Type""application/x-www-form-urlencoded; charset=utf-8");
        
while (reqData.indexOf('/'!= -1
        {
            reqData = reqData.replace('/''%2F');
        }
        reqData 
= reqData.replace(/\</g, "%3D");
        reqData 
= reqData.replace(/\>/g, "%3E");
        
//发送请求数据给云端ASPX程序
        req.send(reqData);
        
if (!async) 
        {
            
if (req.status == 200
            {
                
return req.responseText;
            } 
            else 
            {
                alert(
'cloud server error');
            }
        }
复制代码

 

不多写了,童鞋们知道怎么回事了吧?

现在技术日新月异,终端程序层次不齐,有XAML,HTML5等等,UI虽然越来越绚丽美观了,应用终端也越来越多了,如Android, WP7等,但不变的是后端的服务。精通C#或Java的童鞋赶紧加入云计算的后台来吧!!!

posted on   智艾悦  阅读(734)  评论(2编辑  收藏  举报

编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
< 2011年6月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 1 2
3 4 5 6 7 8 9

导航

统计

点击右上角即可分享
微信分享提示