您好,欢迎访问一九零五行业门户网

MVC2 中某些控件的用法

10.textbox , hidden %=html.textbox(input1) % %=html.textbox(input2,model.categoryname,new{ @style = width:300px; }) % %=html.textbox(input3, viewdata[name],new{ @style = width:300px; }) % %=html.textboxfor(a = a.categoryname, new { @style
10.textbox , hidden
a.categoryname, new { @style = width:300px; })%>
生成结果:
11.textarea
a.categoryname, 3, 3, null)%>
生成结果:
beverages
beverages
12.checkbox
a.isvaild, new { @class = checkbox })%>
生成结果:
13.listbox
a.categoryname, (selectlist)viewdata[categories])%>
   生成结果:
beverages
condiments
confections
dairy products
grains/cereals
meat/poultry
produce
seafood
beverages
condiments
confections
dairy products
grains/cereals
meat/poultry
produce
seafood
14.dropdownlist
a.categoryname, (selectlist)viewdata[categories], --select one--, new { @class = dropdownlist })%>
  生成结果:
--select one--
beverages
condiments
confections
dairy products
grains/cereals
meat/poultry
produce
seafood
--select one--
beverages
condiments
confections
dairy products
grains/cereals
meat/poultry
produce
seafood
15.partial 视图模板
webform里叫自定义控件。功能都是为了复用。但使用上自定义控件真的很难用好。
  看清楚了没有等号的。

16 mvc中的模糊查询和精确查询: 
    var talk = dbtalk.talk.where(m => m.name.indexof(keyword)>=0);//模糊查询
  dbtalk.talk.where(m => m.name.equals(keyword) == true);//精确查询
应用:
在控制器中的action:
      public actionresult search()
        {
           string keyword = request.form[keyword];
           var talk = dbtalk.talk.where(m => m.name.indexof(keyword)>=0);//dbtalk.talk.where(m => m.name.equals(keyword) == true);//
           if (talk == null)
           { viewdata[error] = 未找到相关信息!; }
           else
           { viewdata[error] = yes!;}
           viewdata.model = talk; //视图页面数据
           return view();
        }
view中代码:
//引入models
       { %>
|
                |
其它类似信息

推荐信息