[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

asp.net querystring

<asp:textbox id="txtMfgPartNum"  runat="server" Text='<% Request.QueryString["search"] %>'  />
OR
<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?

Thanks,
0
ITsolutionWizard
Asked:
ITsolutionWizard
  • 2
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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='<%# "http://www.website.com/" + request.querystring("ID") + ".pdf" %>' />Or (my preference) like this: <asp:TextBox runat="server" ID="Proof" Text='<%# String.Format("http://www.website.com/{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
0
 
ITsolutionWizardAuthor Commented:
i don't understand. please show me the exact codes solution
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Being on mobile... not so easy...

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

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now