We help IT Professionals succeed at work.

vb.net pass querystring to asp:textbox

Wayne Barron
Wayne Barron asked
on
156 Views
Last Modified: 2017-04-25
Hello All;

I found out that I cannot do something like this.
Cannot have a codeblock in the asp tag.
<asp:TextBox ID="email" runat="server"><%=Request.QueryString("email") %></asp:TextBox>

Open in new window


I can do it old school.
(But this causes the following error:
 Invalid postback or callback argument.)
<input type="text" ID="email" name="email" readonly value="<%=Request.QueryString("email") %>" />

Open in new window


So, what to do?
How can I pass the querystring value to the field, without causing an error, and get the data, to finish processing the form?
I read that I could do an Eventhandler, however. I have no idea on where to even start on that one.

Thanks All
Carrzkiss
Comment
Watch Question

Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer / Applications Consultant
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Author, Web Developer
CERTIFIED EXPERT
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer / Applications Consultant
CERTIFIED EXPERT

Commented:
yes you can but probably you need to do it via code behind in form load event instead
yea, it should be page load instead of form load : )
Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer / Applications Consultant
CERTIFIED EXPERT

Commented:
btw, your scripts posted should work well.

<script runat="server">
    Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs) Handles Me.Load
        Myemail.Text = Request.QueryString("email")
    End Sub
</script>

Open in new window

Wayne BarronAuthor, Web Developer
CERTIFIED EXPERT
Top Expert 2009

Author

Commented:
I found the code from an asp.net forum to use.
Easy to implement and works like a charm.

Wayne

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.