87,997
社区成员




//后台定义个方法:
private string SetMsgType(int idx)
{
string[] types = new string[4] { "basic", "news", "music", "userapi" };
return (Session["module"].ToString() == types[idx]) ? " selected=\"true\"" : "";
}
视图:
<select id="MsgType" class="sel span6" onchange="showMsgTypeTips();" name="MsgType">
<option value="basic"<%=SetMsgType(0) %>>基本文字回复</option>
<option value="news"<%=SetMsgType(1) %>>基本混合图文回复</option>
<option value="music"<%=SetMsgType(2) %>>基本语音回复</option>
<option value="userapi"<%=SetMsgType(3) %>>自定义接口回复</option>
</select>
第二种:js选中
<select id="MsgType" class="sel span6" onchange="showMsgTypeTips();" name="MsgType">
<option value="basic">基本文字回复</option>
<option value="news">基本混合图文回复</option>
<option value="music">基本语音回复</option>
<option value="userapi">自定义接口回复</option>
</select>
<script type="text/javascript">
document.getElementById('MsgType').value = '<%=Session["module"].ToString()%>';//选中
</script>