hi
refer below link:
http://www.aspforums.net/Threads/360946/How-to-hide-remove-ASPX-extension-in-URL-in-ASPNetaspx/
I used above code for my website:
here are codes in default.aspx page:
<asp:DataList ID="DLMostanad" runat="server" RepeatDirection="Vertical" CssClass="dLmostanad">
<ItemTemplate>
<div id="MainDL14">
<asp:ImageButton ID="ImageButton1" runat="server" CssClass="imgconM" ImageUrl="~/Image/Main/Continue.gif"
CommandArgument='<%# Eval("ID")%>' OnClick="ContinueMostanad" ForeColor="Transparent"
AlternateText="View"></asp:ImageButton>
</div>
</ItemTemplate>
</asp:DataList>
and
protected void ContinueMostanad(object sender, ImageClickEventArgs e)
{
ImageButton ImgEdit = (ImageButton)sender;
Response.Redirect("Mostanad/" + ImgEdit.CommandArgument);
}
and global.asax:
static void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("CustomerDetails", "Mostanad/{Id}", "~/detail.aspx");
}
and in detail.aspx page I used datalist that bind it from database according to Id from default.aspx page:
private void ViewDocInfo(int data1)
{
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand _cmd = General.GetCommand("Documentry_ViewMostanadInfo", conn))
{
_cmd.Parameters.AddWithValue("@id", data1);
conn.Open();
SqlDataReader _dr = _cmd.ExecuteReader();
while (_dr.Read())
{
LblMnameH.Text = _dr["Name"].ToString();
LblMname.Text = _dr["Name"].ToString();
Lblcode.Text = _dr["code"].ToString();
LblsecM.Text = _dr["SectionName"].ToString();
}
}
}
}
if (!IsPostBack)
{
int data1 = Convert.ToInt32(this.Page.RouteData.Values["Id"].ToString());
ViewDocInfo(data1);
}
but when I click imagebutton in default.aspx and direct to detail.aspx page this error happen:
Server Error in '/' Application.
Cannot use a leading .. to exit above the top directory.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Cannot use a leading .. to exit above the top directory.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
what should I do?
Best regards
neda