成人AV在线无码|婷婷五月激情色,|伊人加勒比二三四区|国产一区激情都市|亚洲AV无码电影|日av韩av无码|天堂在线亚洲Av|无码一区二区影院|成人无码毛片AV|超碰在线看中文字幕

打開Visual Studio 2015

首先,我們需要打開Visual Studio 2015。在開始菜單中找到并點擊打開該程序。創(chuàng)建新項目在Visual Studio的界面中,選擇“文件”-gt;“新建”-gt;“項目”,彈出一個新建項目

首先,我們需要打開Visual Studio 2015。在開始菜單中找到并點擊打開該程序。

創(chuàng)建新項目

在Visual Studio的界面中,選擇“文件”-gt;“新建”-gt;“項目”,彈出一個新建項目的窗口。

選擇Web應(yīng)用程序模板

在新建項目窗口中,選擇“ Web應(yīng)用程序”,然后點擊確定按鈕。

選擇模板

在模板選擇界面中,選擇“WebForm模板”,點擊確定按鈕。

添加新建項

在解決方案資源管理器中,右鍵點擊解決方案,選擇“添加”-gt;“新建項...”來添加一個新的Web窗體。

添加Web窗體

在新建項窗口中,選擇Web窗體,并設(shè)置名稱,然后點擊添加按鈕。

在文件中添加代碼

在打開的文件中,添加以下代碼:

```

lt;%@ Page Language"C" AutoEventWireup"true" CodeBehind"" Inherits"WebApplication11.WebForm1" %gt;

lt;!DOCTYPE htmlgt;

lt;html xmlns""gt;

lt;head runat"server"gt;

lt;meta http-equiv"Content-Type" content"text/html; charsetutf-8" /gt;

lt;titlegt;獲取自動生成的編號lt;/titlegt;

lt;script src"Scripts/jquery-1.10.2.js"gt;lt;/scriptgt;

lt;scriptgt;

function fRandomBy(under, over) {

switch (arguments.length) {

case 1: return parseInt(Math.random() * under 1);

case 2: return parseInt(Math.random() * (over - under 1) under);

default: return 0;

}

}

$(function () {

var random fRandomBy(1, 100);

alert(random);

$("lt;% %gt;").val(random);

});

lt;/scriptgt;

lt;/headgt;

lt;bodygt;

lt;form id"form1" runat"server"gt;

lt;divgt;

lt;asp:Button ID"btnRandom" runat"server" Text"獲取自動生成的編號" OnClick"btnRandom_Click" /gt;

lt;/divgt;

lt;asp:HiddenField ID"hd" runat"server" /gt;

lt;/formgt;

lt;/bodygt;

lt;/htmlgt;

```

在后臺文件中添加代碼

在后臺文件中,添加以下代碼:

```c

using System;

using ;

using ;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace WebApplication11

{

public partial class WebForm1 :

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void btnRandom_Click(object sender, EventArgs e)

{

string random ; // 獲取前臺js產(chǎn)生的自動編號

Response.Write(random);

}

}

}

```

在瀏覽器中查看效果

右鍵點擊,選擇“在瀏覽器中打開”。點擊按鈕后,你就會看到生成的值在頁面上顯示了出來。

通過以上步驟,你就可以在C后臺代碼中獲取由前端自動生成的編號了。希望這篇經(jīng)驗對你的工作和學(xué)習(xí)有所幫助!

標(biāo)簽: