我有一个使用 vb.net 在 Visual studio 2012 中构建的 Web 表单项目。它针对 4.8 vb .net 框架。该项目正在进行重大修改,因此我正在构建一个新项目。我最近升级到了 Visual Studio 2022。
为了构建新页面,我向项目添加一个新的 Web 表单页面,并从旧项目复制页面内容。
我从旧项目中复制了 4 页,并遇到了一些奇怪的行为。我正在将一个值从 HTML 选择对象传递到处理页面,并且正在传递的值被读取为 null。
表格(摘自页面):
<form method="post" action="multiparish2.aspx">
<div style="width:40%; min-width:300px; margin:0 auto;" class="arial10pt">
Welcome User, <br />
<br />
Your Login represents more than one parish.
Select the parish for which you are reporting:<br />
<br/>
<select name="par_num" id="par_num" title="par_num" style="width:100%;">
<option value=""></option>
<option value="271">All Saints Catholic, Albany</option>
<option value="278">All Saints on Hudson, Mechanicville, Stillwater</option>
<option value="18">Annunciation, Ilion</option>
<option value="254">Black Catholic Apostilate, Menands</option>
<option value="109">Blessed Sacrament, Bolton Landing</option>
<option value="20">Blessed Sacrament, Mohawk</option>
<option value="193">Blessed Sacrament + Shrine, Albany</option>
<option value="194">Cathedral of the Immaculate Conception, Albany</option>
<option value="273">Christ Our Light, Loudonville</option>
<option value="96">Christ Sun of Justice, Troy</option>
<option value="144">Christ the King, Westmere</option>
<option value="104">Corpus Christi, Round Lake</option>
<option value="27">Holy Cross, Morris</option>
<option value="35">Holy Cross, Salem</option>
<option value="64">Holy Family, Little Falls</option>
<option value="264">Holy Mother and Child, Corinth</option>
<option value="160">Holy Spirit, East Greenbush</option>
<option value="266">Holy Spirit, Gloversville</option>
<option value="251">Holy Trinity, Cohoes</option>
<option value="255">Holy Trinity, Johnstown</option>
<option value="263">Holy Trinity, Hudson</option>
<option value="19">Immaculate Conception, Glenville</option>
<option value="37">Immaculate Conception, Hoosick Falls</option>
<option value="203">Immaculate Conception, New Lebanon</option>
<option value="257">Immaculate Heart of Mary, Watervliet</option>
<option value="260">Korean Apostolate, Colonie</option>
<option value="270">Mater Christi, Albany</option>
<option value="48">Notre Dame-Visitation, Schuylerville</option>
<option value="206">Our Lady of Fatima Church, Delanson</option>
<option value="43">Our Lady of Grace, Ballston Lake</option>
<option value="272">Our Lady of Hope, Copake Falls</option>
<option value="269">Our Lady of Hope, Fort Plain</option>
<option value="252">Our Lady of Hope, Whitehall</option>
<option value="45">Our Lady of Mount Carmel, Schenectady</option>
<option value="120">Our Lady of the Annunciation, Queensbury</option>
<option value="17">Our Lady of the Assumption, Latham</option>
<option value="262">Our Lady of the Valley, Middleburgh</option>
<option value="112">Our Lady of Victory, Grafton, Troy</option>
<option value="212">Our Lady Queen of Apostles, Frankfort</option>
<option value="276">Our Lady Queen of Peace, Rotterdam</option>
<option value="294">Pastoral Center, Albany</option>
<option value="187">Sacred Heart, Castleton on Hudson</option>
<option value="119">Sacred Heart, Cairo</option>
<option value="1">Sacred Heart, Lake George</option>
<option value="22">Sacred Heart, Margaretville</option>
<option value="51">Sacred Heart, Sidney</option>
<option value="169">Sacred Heart, Stamford</option>
<option value="148">Sacred Heart, Tribes Hill</option>
<option value="66">Sacred Heart, Troy</option>
<option value="163">Sacred Heart of Jesus, Albany</option>
<option value="265">Sacred Heart-Immaculate Conception, Haines Falls</option>
<option value="38">St. Adalbert, Schenectady</option>
<option value="185">St. Ambrose, Latham</option>
<option value="188">St. Ann, Fort Ann</option>
<option value="85">St. Anthony, Schenectady</option>
<option value="56">St. Anthony of Padua, Troy</option>
<option value="209">St. Augustine, Troy</option>
<option value="151">St. Cecilia, Fonda</option>
<option value="181">St. Cecilia, Warrensburg</option>
<option value="133">St. Clare, Colonie</option>
<option value="36">St. Clement, Saratoga Springs</option>
<option value="128">St. Edward the Confessor, Clifton Park</option>
<option value="10">St. Francis de Sales, Herkimer</option>
<option value="277">St. Francis of Assisi, Albany</option>
<option value="149">St. Francis of Assisi, Northville</option>
<option value="50">St. Gabriel the Archangel, Rotterdam</option>
<option value="177">St. Henry, Averill Park</option>
<option value="274">St. Issac Jogues, Chestertown</option>
<option value="164">St. James, North Creek</option>
<option value="125">St. James, Chatham</option>
<option value="29">St. Joan of Arc, Menands</option>
<option value="7">St. John the Baptist, Greenville</option>
<option value="92">St. John the Baptist, Newport</option>
<option value="140">St. John the Baptist, Valatie</option>
<option value="69">St. John the Baptist, Walton</option>
<option value="115">St. John the Evangelist, Schenectady</option>
<option value="259">St. John the Evangelist and St. Joseph, Rensselaer</option>
<option value="110">St. Joseph, Broadalbin</option>
<option value="54">St. Joseph, Fort Edward</option>
<option value="5">St. Joseph, Greenfield Ctr</option>
<option value="200">St. Joseph, Greenwich</option>
<option value="32">St. Joseph, Dolgeville</option>
<option value="40">St. Joseph, Schenectady</option>
<option value="107">St. Joseph, Scotia</option>
<option value="267">St. Joseph, Stuyvesant</option>
<option value="59">St. Joseph, Troy</option>
<option value="81">St. Joseph, Worcester</option>
<option value="261">St. Joseph the worker, Richfield Springs, West Winfield</option>
<option value="82">St. Jude the Apostle, Wynantskill</option>
<option value="279">St. Kateri Tekakwitha, Schenectady</option>
<option value="98">St. Lucy's/St. Bernadette, Altamont</option>
<option value="41">St. Luke, Schenectady</option>
<option value="23">St. Madeleine Sophie, Guilderland</option>
<option value="145">St. Mary, Albany</option>
<option value="102">St. Mary, Amsterdam</option>
<option value="108">St. Mary, Ballston Spa</option>
<option value="129">St. Mary, Coxsackie</option>
<option value="137">St. Mary, Cooperstown</option>
<option value="176">St. Mary, Glens Falls</option>
<option value="4">St. Mary, Granville</option>
<option value="28">St. Mary, Nassau</option>
<option value="3">St. Mary, Oneonta</option>
<option value="131">St. Mary Clinton Heights, Rensselaer</option>
<option value="210">St. Mary Crescent, Crescent</option>
<option value="207">St. Mary of the Asumption, Waterford</option>
<option value="12">St. Mary/St. Paul, Hudson Falls</option>
<option value="68">St. Matthew, Voorheesville</option>
<option value="94">St. Michael, Cohoes</option>
<option value="158">St. Michael the Archangel, S. Glens Falls</option>
<option value="61">St. Michael the Archangel, Troy</option>
<option value="162">St. Patrick, Cambridge</option>
<option value="106">St. Patrick, Athens</option>
<option value="156">St. Patrick, Catskill</option>
<option value="114">St. Patrick, Ravena</option>
<option value="95">St. Paul the Apostle, Hancock</option>
<option value="47">St. Paul the Apostle, Schenectady</option>
<option value="150">St. Peter, Delhi</option>
<option value="186">St. Peter, Saratoga Springs</option>
<option value="84">St. Pius X, Loudonville</option>
<option value="103">St. Stanislaus, Amsterdam</option>
<option value="8">St. Stephen, Hagaman</option>
<option value="80">St. Theresa of the Child Jesus, Windham</option>
<option value="122">St. Thomas the Apostle, Cherry Valley</option>
<option value="153">St. Thomas the Apostle, Delmar</option>
<option value="78">St. Vincent de Paul, Albany</option>
<option value="196">St. Vincent de Paul, Cobleskill</option>
<option value="213">Sts. Anthony & Joseph, Herkimer</option>
<option value="99">Sts. Joseph/Michael/Mt. Carmel, Amsterdam</option>
<option value="275">Transfiguration, Speigletown</option>
</select><br />
<div style="text-align:right"><br /> <input type="submit" value="Select Parish"/></div>
</div>
</form>
表单处理页面:
<%
If Request.Form("par_num") = "" Then
'Response.Write("Par_Num: " & Request.Form("Par_Num"))
Response.Redirect("multiparish.aspx?msg=2")
Else
'do something
end if
%>
请求的值。表单(“Par_Num”)为空,并将我重定向到选择教区的页面,无论我选择哪个教区。该代码在使用 VS 2012 构建的旧项目中运行良好。有人可以解释为什么我得到空值吗?
您需要控制
runat="Server"
:
<select name="par_num" id="par_num" title="par_num" runat="Server" style="width:100%;">