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

#1 DocNet   User is offline

  • D.I.C Head

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

ASP.NET(C#) Query String?

Posted 01 December 2012 - 04:01 AM

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,

when i click on first data:
on second

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);

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   User is offline

  • Professional Lurker
  • member icon

Reputation: 448
  • View blog
  • Posts: 1,504
  • 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