Asp code

What is wrong in this code

<% If User  =  "Kiran" Then %>
  <p>kiran</p>

 <% Else %>

    <p>Not kiran</p>
<% End If %>
LVL 17
Kiran SonawaneProject LeadAsked:
Who is Participating?
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
this code:
<% 
Dim User
If User = "Kiran" Then 
%>
  <!-- #include file="admin.inc" -->
<%
      Else

%>
                   <!-- #include file="user.inc" -->
<%    
 End If 
%>

Open in new window


will ALWAYS include user.inc because the variable "User" is never assigned a value. you need to assign a value to it first, then check with the IF statement
0
 
Loganathan NatarajanLAMP DeveloperCommented:
try this,
<% 
Dim User
If User = "Kiran" Then 
		response.Write("<p>kiran</p>");

	Else
			response.Write("<p>Not kiran</p>");
    
 End If %>

Open in new window

0
 
Kiran SonawaneProject LeadAuthor Commented:
Thanks for quick response. Last doubt what if I need include the file

<%
Dim User
If User = "Kiran" Then
%>
  <!-- #include file="admin.inc" -->
<%
      Else

%>
                   <!-- #include file="user.inc" -->
<%    
 End If
%>

is above correct
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Kiran SonawaneProject LeadAuthor Commented:
Guys suggest..
0
 
Loganathan NatarajanLAMP DeveloperCommented:
it should work,
<% 
    if Request.QueryString("param")="2" then 
%> 
        <!--#include file="2.htm"--> 
<% 
    else 
%> 
        <!--#include file="1.htm"--> 
<% 
    end if 
%>

Open in new window

0
 
Loganathan NatarajanLAMP DeveloperCommented:
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Nothing looks wrong with the code as is.  What is the problem you are having?
0
 
Wayne BarronAuthor, Web DeveloperCommented:
The code that you originally was using, is OK.
Using an INCLUDE in the middle, is fine.

Doing response,write, is not always a good thing to do, only use it in places that it is needed, other than that, you do not have to do Response.write, as it makes for harder to design layouts.

Carrzkiss
0
 
nap0leonCommented:

What is wrong in this code

<% If User  =  "Kiran" Then %>
  <p>kiran</p>

 <% Else %>

    <p>Not kiran</p>
<% End If %>

If "User" is defined, there is nothing wrong with the code.
Where you have "<p>kiran</p>" and "<p>Not kiran</p>", you can put whatever you want.  (HTML, more ASP code, etc.)
0
 
Kiran SonawaneProject LeadAuthor Commented:
Thanks everyone
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.