We help IT Professionals succeed at work.

Asp code

Kiran Sonawane
on
What is wrong in this code

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

 <% Else %>

    <p>Not kiran</p>
<% End If %>
Comment
Watch Question

Loganathan NatarajanLAMP Developer
CERTIFIED EXPERT
Commented:
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

Kiran SonawaneProject Lead
CERTIFIED EXPERT
Top Expert 2011

Author

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
Kiran SonawaneProject Lead
CERTIFIED EXPERT
Top Expert 2011

Author

Commented:
Guys suggest..
Loganathan NatarajanLAMP Developer
CERTIFIED EXPERT

Commented:
it should work,
<% 
    if Request.QueryString("param")="2" then 
%> 
        <!--#include file="2.htm"--> 
<% 
    else 
%> 
        <!--#include file="1.htm"--> 
<% 
    end if 
%>

Open in new window

Loganathan NatarajanLAMP Developer
CERTIFIED EXPERT

Commented:
Scott FellDeveloper & EE Moderator
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013

Commented:
Nothing looks wrong with the code as is.  What is the problem you are having?
Wayne BarronAuthor, Web Developer
CERTIFIED EXPERT
Top Expert 2009
Commented:
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
Top Expert 2011

Commented:

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.)
Web Ninja at large
CERTIFIED EXPERT
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
Kiran SonawaneProject Lead
CERTIFIED EXPERT
Top Expert 2011

Author

Commented:
Thanks everyone

Explore More ContentExplore courses, solutions, and other research materials related to this topic.