Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 258283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:10:04+00:00 2026-05-11T22:10:04+00:00

I’m writing am ASP.NET/C# project, it’s a simple blog page with commnents. Problem I’m

  • 0

I’m writing am ASP.NET/C# project, it’s a simple blog page with commnents.
Problem I’m having when button click you see comments load original blogload plus blogs and comments, trying to get it to load blog/comment selected only.
If I try not to load blog in page_load or have it only do if not postback nothing is displayed. Any help would be appreciated.
PS I know there are many blog engines out there but have specific reason.

protected void Page_Init(object sender, EventArgs e)
{
    //ParseControls(GlobalVar.pathxsltver);
    //        BindInfo();
}
private void ParseControls(string myxslt)
{

    //load the data
    FileStream fs = new FileStream(Server.MapPath ( GlobalVar.compathver), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
    DataSet dset = new DataSet();
    dset.ReadXml(fs);
    fs.Close();
    XPathDocument xdoc = new XPathDocument(Server.MapPath(GlobalVar.pathver ));
    XmlDocument mydoc = new XmlDocument();
    XPathNavigator navigator = xdoc.CreateNavigator();
    XPathExpression expression = navigator.Compile("BlogItems/Blog");
    expression.AddSort("ID", XmlSortOrder.Descending, XmlCaseOrder.UpperFirst, string.Empty, XmlDataType.Text);
    XPathNodeIterator iterator = navigator.Select(expression);
    int TheCnt = 0;
    int cnt = GlobalVar.BlogCntDisplay;
    string st = "<BlogItems>";
    foreach (XPathNavigator item in iterator)
    {
        TheCnt++;
        string sid = item.SelectSingleNode("ID").Value;
        st = st + "<Blog id=\"" + sid + "\">" + item.InnerXml;
        st = st + "<ComCnt>" + MyFunc.CountComments (sid,dset) +  "</ComCnt></Blog>";
        if (TheCnt == cnt) { break; }
    }
    st = st + "</BlogItems>";
    mydoc.LoadXml(st);
    XslCompiledTransform transform = new XslCompiledTransform();
    XsltSettings settings = new XsltSettings(true,true);
    transform.Load(Server.MapPath(myxslt),settings,null);
    StringWriter sw = new StringWriter();
    transform.Transform(mydoc, null, sw);
    string result = sw.ToString();
    //remove namespace
    result = result.Replace("xmlns:asp=\"remove\"", "");
    //parse control
    Control ctrl = Page.ParseControl(result);
    //find control to add event handler
    //Boolean test =  phBlog.FindControl("btnComment2").i;
   phBlog.Controls.Add(ctrl);
    XmlNodeList  nList = mydoc.SelectNodes("//BlogItems/Blog/ID");
   foreach (XmlNode objNode in nList)
   { 
    Button btnComment = (Button) phBlog.FindControl("btnComment"+objNode.InnerText );
    btnComment.CommandArgument = objNode.InnerText ;
       btnComment.BorderWidth = 0 ;

    btnComment.Command += new CommandEventHandler(Button1_Click);
   }
}

protected void Page_Load(object sender, EventArgs e)
{

   //if (!Page.IsPostBack )
   //{ParseControls(GlobalVar.pathxsltver);}
    ParseControls(GlobalVar.pathxsltver);
   }

protected void Button1_Click(object sender, CommandEventArgs e)
{
    Label1.Text = "Comm hit : " + e.CommandArgument.ToString();
    ParseControls(GlobalVar.blogcommentsver ); 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:10:04+00:00Added an answer on May 11, 2026 at 10:10 pm

    You’re question is kind of vague, but if I understand you correctly, you’re wondering why the entire page refreshes when you just want to handle the button click?

    Whenever you do any kind of postback, and that includes handling any events, the entire page is re-rendered. More than that, you’re working with a brand new instance of your page class. The old one is dead and gone. That’s just the way the web normally works.

    If you only want to reload a part of the page, you need to use ajax. In ASP.Net land, that means placing your comments section inside an UpdatePanel control that can be refreshed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I've tracked down a weird MySQL problem to the two different ways I was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.