ASP.net と VB.Net を Visual Studio 2012 Web のコード ビハインドとして使用して、(ブートストラップで) 非常に単純なデータ入力アプリケーションを開発しています。
ファーストネームを取得するための次の html があるとします。
<form id="form1" runat="server">
<div style="padding:20px">
<div class="form-group">
<label for="firstname">Firstname</label>
<input type="text" class="form-control" id="firstname" name="firstname" placeholder="" style="max-width:450px" maxlength="60" />
<small class="text-muted">Enter your first name.</small>
</div>
<button runat="server" type="submit" class="btn btn-primary" onserverclick="btnSubmit_ServerClick" >Submit</button>
</div>
</form>
およびその値を処理するための対応するコード ビハインド:
Protected Sub btnSubmit_ServerClick(sender As Object, e As EventArgs)
Dim fname As String = Request.Form("firstname").ToString
End Sub
runat="server"
html の firstname フィールドで使用したくないとします。Request.Form("firstname").ToString
tag を設定した場合にのみ機能することがわかりname="firstname"
ます。タグのみを設定した場合id
(name
タグではなく)、それは考慮されません。私の場合、サーバー側にのみ<input type="text" class="form-control" id="firstname" placeholder="" style="max-width:450px" maxlength="60" />
がある場合Request.Form("firstname")
は、NULL を返します。
私もRequest.Form
運が悪いです。タグNameValueCollection
のみを設定したコンポーネントでコレクションが満たされていることがわかります。name
私の質問は、ID のみを設定した html コンポーネントを操作するためにサーバー コードを変更することは可能ですか?