Html代码:
<input type="radio" name="searchOption" value="SearchInPage" required>Search Page</input>
<input type="radio" name="searchOption" value="SearchInSite" checked>Search Site</input>
C#代码:
if(this.Request.Form["searchOption"]!=null)
{
string options = Request.Form["searchOption"].ToString();
if(options.equals('searchInSite'))
{
searchInSite();
}
else
{
searchInPage();
}
}
我无法获得if条件中的值吗?
答案 0 :(得分:0)
SearchInSite
代替searchInSite
。案件不匹配发生在这里。
if(options.equals("SearchInSite"))
答案 1 :(得分:0)
try this:
HTML:
<input type="radio" name="searchOptionPage" value="SearchInPage" required/>Search Page
<input type="radio" name="searchOptionSite" value="SearchInSite"checked/>Search Site
Code Behind(C#)
if(this.Request.Form["searchOption"]!=null)
{
string options = Request.Form["searchOption"].ToString();
if(options.equals('SearchInSite'))
{
var searchInSite=searchOptionSite.Text;
searchInSite();
}
else
{
var searchInPage=searchOptionPage.Text;
searchInPage();
}
}