在其他aspx文件中包含aspx文件
问题描述:
<% if (Session["desig"].ToString() == "Developer"){%>
<td>
<select name='zone' id="zone" onchange="showLoc(this.value,'mlodg_loc')">
<option value="Select Zone">Select Zone</option>
<option value="East">East</option>
<option value="West">West</option>
<option value="North">North</option>
<option value="South1">South1</option>
<option value="South2">South2</option>
<option value="South3">South3</option>
</select>
</td>
<%}
else
{%>
<td>
<select name='zone' id="Select1" onchange="showLoc(this.value,'mlodg_loc')">
<option value="Select Zone">Select Zone</option>
<option value="<%#Session["zone"]%>"><%# Session["zone"].ToString() %></option>
</select>
</td>
<%}%>
如果我直接编写,上面的代码可以正常工作,我试图用其他代码编写文件和主文件中,我做了 Response.WriteFile( zone.aspx)
the code above is working fine if I am writing it directly, I tried to write this code in other file and in main file i did Response.WriteFile("zone.aspx")
我如何包含它有没有什么方法可以包含,并且还想知道一种更好的方法来编写以上语句。
How can i include it is there any way to include and also would like to know a better way to write the above statements.
谢谢
答
UserControls $code>为此在asp.net中存在,为此创建一个 .ascx 文件您拥有的一段代码,并将其用作任何地方的控件。
UserControls
are there in asp.net for this purpose, make a .ascx file for this piece of code u have, and use it as a control anywhere.