![](/img/trans.png)
[英]How to create a new .cshtml page in a project that can be seen through a URL
[英]how can add the anchor tag title as URL and create as new page
我们如何才能将锚标记标题添加为url,并且这是作为新网站的工作,我将global.asax中的url重定向,但这并不是我想要的
routes.MapPageRoute("-", "-", "~/Jobs/ShowResume.aspx");
你也可以尝试更多
和另一个页面,我正在使用数据列表显示一些内容
foreach (DataListItem item in DataList1.Items)
{
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{
try
{
Label lbldate = (Label)item.FindControl("lbldate");
string idate = lbldate.Text.Replace("/","-");
string date = TimeAgo(Convert.ToDateTime(idate));
lbldate.Text = date;
HyperLink hreflink = (HyperLink)item.FindControl("hreftitle");
hreflink.NavigateUrl = "../-?" + (hreflink.Text).ToString().Trim().Replace(" ", "-");
}
catch (Exception)
{
}}
}
完成此操作后,我得到一个URL http:// localhost:55389 / NXG-Alpha /-?S / w-In-a-Core-IT-Company
但我想要http:// localhost:55389 / NXG-Alpha / S / w-In-a-Core-IT-Company
有可能请建议我一些解决方法
确保正确解析您的日期。 我看不到将日期结果放入URL的位置。 因此将假定与Nav URL不相关。
string dateString = "4/23/2015";
string controlName = "NXG-Alpha";
string controlSubDirectory = "S";
string controlPage = "w-In-a-Core-IT-Company";
// If we have a valid date
DateTime dateTime = DateTime.MinValue;
if (DateTime.TryParse(dateString, CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out dateTime))
{
// Setup Navigation URL
HyperLink hreflink = (HyperLink)item.FindControl("hreftitle");
hreflink.NavigateUrl = string.Format("../{0}/{1}/{2}", controlName, controlSubDirectory, controlPage);
}
else
{
// Date Error
// TODO...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.