Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on

If condition on Html with Asp

Hi experts, How to write a condition on Html with Asp session? As code shown below with an aim that if the Session is empty then the Session will have its new value as "Big E".

<script>
    if '<%= Session("Allow")%>' == "" then
        <%Session("Allow")="Big E"%>
    end if
<script>
SOLUTION
Avatar of Ishaan Rawat
Ishaan Rawat
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Whing Dela Cruz

ASKER

Hi Shaun, your solution is running correctly. However, Please allow me to take advantage to ask some more question in relation with this issue wherein I want to put the value of "Allow" in input within the body. here's my code that run with errors.
 
<%
If Session("Allow") = "" Then
   Session("Allow") = "Big E"
   else
   document.getElementById("myCode").value = Session("Allow")
End If
%>
Add a control such as someLabel, a label
<%
If Session("Allow") = "" Then
   Session("Allow") = "Big E"
   else
      someLabel.Text = Session("Allow")
End If
%>

Open in new window

Hi Shaun, you told "someLabel.Text" I wanted to put the value of "Allow in here" <input type="text" id="myCode"> How should I write the code?
<%
If Session("Allow") = "" Then
   Session("Allow") = "Big E"
   else
      myCode.Text = Session("Allow")
End If
%>

Open in new window

Hi, Shaun, I'm getting error, Error Type: Microsoft VbScript runtime. Object required: 'myCode'
Textbox should be server-side
<asp:textbox runat="server" id="myCode" ></asp:textbox>

Open in new window

Hi Shaun, Please understand that I am very beginner of ASP and Html. So, I do not know where to write this, <asp:textbox runat="server" id="myCode" ></asp:textbox>
Inside the aspx page
Hi Shaun, My concern was answered correctly by you both and I really appreciated for that. The second concern is remain unsettled  but i decided to close this question since I need to re-align my codes that might possibly lead me to the answer of . Thank you, for your participation. More power to both of you and God Bless!