日期:2013-09-09  浏览次数:20506 次

在asp下,有时候会使用下面的代码:

<%
if request("m") = "1" then%>
<script language="javascript">
<!--
m_name[0] = "《财经》杂志 ";
//m_period[0] = 6;
init(1, 1, 1);
//-->
</script>
<%
else%>
<script language="javascript">
<!--
m_name[0] = "《财经》杂志 ";
init(0, 1, 1);
//-->
</script>
<%end if%>
<%if request("m") = "2" then%>
<script language="javascript">
<!--
m_name[1] = "《证券市场》周刊(综合刊)";
m_name[2] = "《证券市场》周刊(市场刊)";
init(1, 2, 1);
init(1, 3, 1);
//-->
</script>
<%
else%>
<script language="javascript">
<!--
m_name[1] = "《证券市场》周刊(综合刊)";
m_name[2] = "《证券市场》周刊(市场刊)";
init(0, 2, 1);
init(0, 3, 1);
//-->
</script>
<%end if%>

如果是在ASP.NET下,如何解决呢?

方法1(使用ViewState):(蒙斑竹鸿雪指教,试验成功)

<SCRIPT language="javascript">
            <!--
            
            function howMuch2View(iselect, iview)
            {
                var m1, m2;
                switch(iselect)
                {
                    case 1:
                        m1 = 1;
                        m2 = 0;
                        break;
                    case 2:
                        m1 = 0;
                        m2 = 1;
                        break;
                    default:
                        m1 = 1;
                        m2 = 0;
                        break;
                
                }
                       &nb