Solved querystring

Posted on 2014-08-10
Last Modified: 2014-08-10
<asp:textbox id="txtMfgPartNum"  runat="server" Text='<% Request.QueryString["search"] %>'  />
<asp:textbox id="txtMfgPartNum"  runat="server" Text="<% Request.QueryString["search"] %>"  />

I tried both above. First one does not show the value, 2nd one show invalid code alert.

I just want to see the value inside of the textbox. What should I do?

Question by:ITsolutionWizard
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    This is the explanations and solutions I found for your question:
     You cannot use Generic Server Tags (<% ... %>) or Printing Server Tags (<%= somevar %>) as Attributes of a Server Control.  You can use them in normal, non-server tags because they become Literals.  You are, however, allowed to use Binding Server Tags (<%# ... %>) and Prefix Server Tags (<%$ prefix: Argument %>).  (I don't know the official names for any of these things, but I hope you understand what I am talking about.)The caveat is that if you need some sort of dynamic value for the attribute, then the entire attribute has to be in the tag code. So you can rewrite your code like this: <asp:TextBox runat="server" ID="Proof" Text='<%# "" + request.querystring("ID") + ".pdf" %>' />Or (my preference) like this: <asp:TextBox runat="server" ID="Proof" Text='<%# String.Format("{0}.pdf", request.querystring("ID")) %>' /> Also, if ever need to access something in code for a repeater, you can use the ItemDataBound event for the repeater. There is a special subclass of EventArgs -- RepeaterItemEventArgs -- which gives you access to the item after it is built.

    Open in new window

    I hope this helps

    Author Comment

    i don't understand. please show me the exact codes solution
    LVL 142

    Accepted Solution

    Being on mobile... not so easy...

    This should do:
    <asp:textbox id="txtMfgPartNum"  runat="server" Text="<%# String.Format("{0}" , Request.QueryString["search"] )%>"  />

    Author Closing Comment

    Helpful and quick response.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now