PDA

View Full Version : چرا این کد در قسمت global کار نمی کنه؟!



tree1371
یک شنبه 23 تیر 1392, 19:02 عصر
سلام دوستان . کد بی هایند من این هست :


protected void Button1_Click(object sender, EventArgs e)
{

string url = "sfsdfs/sdfsfs/sdfsfs/sdfsf/";
string[] splits = Regex.Split(url,"/");
Application["num"] = 4;
string Url = Page.GetRouteUrl("ITEMs", new { NAME = "MOHAMMAD" });
Response.Redirect(url);

}



و گلوبال من هم به صورت زیر است :



<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>

<script runat="server">

void Application_Start(object sender, EventArgs e)
{

this.routingData(RouteTable.Routes);

}

void routingData(RouteCollection routes)
{

int num = Convert.ToInt32 (HttpContext.Current.Application["num"]);
string name = string.Empty;
for (int i = 0; i < num; i++)
{
name += "{Name" + i + "}" ;
}

routes.MapPageRoute("ITEMs", name , "~/Default.aspx");

routes.MapPageRoute("ITEMsssss", "cat/{NAME}" + name, "~/ITEM.aspx");






}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown

}

void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs

}

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started

}

void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.

}

</script>




قسمت شرط for کار نمی کنه وقتی کلیک می کنم روی دکمه.چرا؟