?
Solved

Code blocks are not supported in this context

Posted on 2006-05-03
6
Medium Priority
?
4,398 Views
Last Modified: 2008-02-20
Hi,

I am trying to have this in my user control But I am getting error saying code blocks are not supported in this context.

In my user control I am just putting <% if request.querystring("test")="tom" then %>
<asp:textbox id=txt1 />
<%end if%>
0
Comment
Question by:sureshraina
  • 2
  • 2
  • 2
6 Comments
 
LVL 15

Expert Comment

by:deepaknet
ID: 16602766
Rather than this you can do like

<asp:textbox id="txt1" runat="server">

In the codeBehind Page_Load:

if (Request.QueryString("test")  == "tom") then
    txt1.Visible = true
else
   txt1.Visible = false
end if
0
 
LVL 15

Expert Comment

by:deepaknet
ID: 16602773
Correction

Replace == with = in the snippet I have given you. (a bit of C# flavor!)
0
 
LVL 12

Expert Comment

by:bsdotnet
ID: 16602776
Try this, it should work,
        <% If Request("test") = "tom" Then%>
        <asp:TextBox id=txt1 runat=server />
        <%  End If%>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Accepted Solution

by:
bsdotnet earned 2000 total points
ID: 16602820
Either
<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If Request("test") = "tom" Then
            Dim a As New TextBox
            a.ID = "txt1"
            Me.form1.Controls.Add(a)
        End If
    End Sub
</script>

OR

<body>
    <form id="form1" runat="server">
    <div>
       <% If Request("test") = "tom" Then%>
        <asp:TextBox id=txt1 runat=server />
        <%  End If%>
        </div>
    </form>
</body>
0
 
LVL 14

Expert Comment

by:Ramuncikas
ID: 16603414
<%= if request.querystring("test")="tom" then %>
0
 
LVL 14

Expert Comment

by:Ramuncikas
ID: 16603418
Oops...won't work.....sorry
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses

850 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