Hi dharmendr,
Here is what I tried
Guide.aspx
<div class="card-deck mb-3 text-center" style="width: 100%; margin: 0 auto; padding: 10px; background-color: white; font-family: 'Be Vietnam';">
<asp:Repeater ID="repeater1" runat="server">
<ItemTemplate>
<div class="card mb-4 shadow-sm" style="text-align: left; border-radius: 13px;">
<div class="card-body" style="font-size: 9pt; box-shadow: 3px 10px 3px -4px gray; border-radius: 13px;">
<h6><asp:HyperLink ID="hyperlink1" runat="server" NavigateUrl='<%# string.Format("~/aa.aspx?Id={0}", HttpUtility.UrlEncode(Eval("Heading").ToString())) %>' Text='<%# Eval("Heading") %>' style="font-size: 13pt; color: #145c7c; text-decoration: none;">
</asp:HyperLink></h6>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
Guide.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
using (SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Dataregister.mdf;Integrated Security=True"))
{
string query = "SELECT DISTINCT [Heading] FROM [Guide]";
using (SqlCommand cmd = new SqlCommand(query))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
repeater1.DataSource = dt;
repeater1.DataBind();
}
}
}
}
}
}
Article.aspx
<h2>Articles</h2><br />
<asp:Label ID="Label1" runat="server" Text="" Font-Size="13pt"></asp:Label>
<asp:Repeater ID="repeater" runat="server">
<ItemTemplate>
<asp:HyperLink ID="hyperlink1" runat="server" NavigateUrl='<%# string.Format("~/Support/{0}", Eval("Slug")) %>' Text='<%# Eval("Title") %>' Font-Underline="false" style="font-size: 13pt; color: #145c7c;"></asp:HyperLink>
<br />
</ItemTemplate>
<SeparatorTemplate>
<br />
</SeparatorTemplate>
</asp:Repeater>
Article.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.ArticleTitle();
}
if (Request.QueryString["Id"] != null)
{
string Id = Request.QueryString["Id"] as String;
}
}
private void ArticleTitle()
{
// string Heading = "Id";
using (SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Dataregister.mdf;Integrated Security=True"))
{
string query = "SELECT DISTINCT [Title], REPLACE([Title], ' ', '_') [SLUG] FROM [Guide] WHERE Heading = '" + Request.QueryString["Id"] + "'";
using (SqlCommand cmd = new SqlCommand(query))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
repeater.DataSource = dt;
repeater.DataBind();
}
}
}
}
}
Articlebody.aspx
<div>
<h2><asp:Label ID="maintitle" runat="server"></asp:Label></h2>
<h4><asp:Label ID="subtitle" runat="server"></asp:Label></h4>
<asp:Label ID="body" runat="server"></asp:Label>
</div>
Articlebody.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.ArticleBody();
}
if (Request.QueryString["Id"] != null)
{
string Id = Request.QueryString["Id"] as String;
}
}
private void ArticleBody()
{
using (SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Dataregister.mdf;Integrated Security=True"))
{
string blogID = this.Page.RouteData.Values["guide_Id"].ToString();
string query = "SELECT [Body] FROM [Guide] WHERE Title = '" + Request.QueryString["Id"] + "'";
using (SqlCommand cmd = new SqlCommand(query))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Parameters.AddWithValue("@Title", blogID);
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
maintitle.Text = dt.Rows[0]["Heading"].ToString();
subtitle.Text = dt.Rows[0]["Title"].ToString();
body.Text = dt.Rows[0]["Body"].ToString();
}
}
}
}
}
MY Global.asax file for Routing
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
static void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("Articlebody", "Support/{Title}/{Slug}.aspx", "~/Articlebody.aspx");
}
But when I click on the Title to get the string value in the articlebody.aspx page and fetch the body from database and display in page, I get this error below: "That the resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
But the file is there