1 Replies - 899 Views - Last Post: 01 December 2012 - 08:37 AM Rate Topic: -----

#1 DocNet  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 74
  • Joined: 11-October 12

ASP.NET(C#) Query String?

Posted 01 December 2012 - 04:01 AM

Hi,
I need some help with query string,
I load data with enitity framework from mssql database, and all things are succesfully loaded, but... I have some probably stu*id problem, when i try to set "href" i 've problem with query string, string into adress bar is duplicated when i click on some <a href>data</a> from database,

Example:
when i click on first data:
Default.aspx/?show=1
on second
Default.aspx/Default.aspx/show=2

code:
Kategorije(Serbian) == Categories(English)
if (!IsPostBack)
        {
            string output = "";
            DatabaseEntities de = new DatabaseEntities();
            var rez = from p in de.Kategorijes
                      select p;
            foreach (Kategorije k in rez)
            {
                output += String.Format("<a href='Default.aspx/?show={0}'>{1}</a></br>", k.Kategorije_Id.ToString(), k.Naziv_Kategorije);
            }
            Response.Write(output);
        }



I was try to clear query string but still same problem...
In php i used this line of code normally:
$output .= '<li><a href="category.php?show='.$row['id'].'">'.$row['name'].'</a> ('.$check.')</li>';

but in ASP.NET that does not work...

Is This A Good Question/Topic? 0
  • +

Replies To: ASP.NET(C#) Query String?

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 445
  • View blog
  • Posts: 1,501
  • Joined: 28-April 09

Re: ASP.NET(C#) Query String?

Posted 01 December 2012 - 08:37 AM

From this little bit of code there is this would be causing the problem that you stated you're having. You're formatting the string here,
String.Format("<a href='Default.aspx/?show={0}'>{1}</a></br>", k.Kategorije_Id.ToString(), k.Naziv_Kategorije)
. The only thing that will change in this is what is in the {0} and the {1}. Nothing in this small bit of code you've provide affects the Default.aspx part of that string.

Use the debugger and step through this and see what the value of output is before it writes it back to the page.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1