Solved

how to output text in asp.net vb

Posted on 2010-09-16
8
404 Views
Last Modified: 2012-05-10
Hi,

I'm learning asp.net VB and am having troble with what should be a simple problem. I just want to output a string but am having a difficult time figuring out how to do so. I have an asp classic page which just assigns a text string to a variable and then writes the value.

<%
imgop = "<html><body><script type=""text/javascript"">window.parent.CKEDITOR.tools.callFunction('1','/senate/leg.title.jpg');</script></body></html>;"
Response.write imgop
%>

Seems simple but I can't seem to find how to make a variable in asp.net or assign it a value or write the contents. Could someone show me how to do this simple thing? Thanks.

0
Comment
Question by:elliottbenzle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 33689354
http://forums.asp.net/p/999974/1328758.aspx
Html; 
<TR style="color: <asp:Literal ID='myStyle' runat='server'/>">
Code 


protected System.Web.UI.WebControls.Literal myStyle;

private void Page_Load(object sender, System.EventArgs e)
{
	string fontColor = "";
	if (Request.QueryString["condition1"] == "1")
	{
		fontColor="Red";
	}
	else
	{
		fontColor = "Black";
	}

	myStyle.Text = fontColor;

}

Open in new window

0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33689355
in your html just do this

<asp:label runat="server" id="label1" />

Now when in your code you say
label1.text="Whatever you want to say"

The line "Whatever you want to say" will show up wherever the asp:Label control is on the page

Source: http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_21140575.html
0
 
LVL 4

Author Comment

by:elliottbenzle
ID: 33689470
It's not quite the same. If I use an asp: label the output is wrapped in a <span> tag. Like this:

<span id="label1"><html><body><script type="text/javascript">window.parent.CKEDITOR.tools.callFunction('1','admin_images/elliott.jpg');</script></body></html>;</span>

I need the results to look like this:
<html><body><script type="text/javascript">window.parent.CKEDITOR.tools.callFunction('1','admin_images/elliott.jpg');</script></body></html>;



Is there a way to have this code make the same output but without the <span> tag?

<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<% label1.text="<html><body><script type=""text/javascript"">window.parent.CKEDITOR.tools.callFunction('1','admin_images/elliott.jpg');</script></body></html>;" %>
<asp:label runat="server" id="label1" />
0
Industry Leaders: 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 7

Accepted Solution

by:
klakkas earned 500 total points
ID: 33689500
Try using the Literal control and in your code behind say:

Literal1.text = "your data"
0
 
LVL 4

Author Comment

by:elliottbenzle
ID: 33689580
Yes, that did it. Thanks.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33689598
>> Try using the Literal control and in your code behind say: Literal1.text = "your data"

That's what I also said in the first comment !

0
 
LVL 28

Expert Comment

by:sybe
ID: 33689637
If you define a public variable in the code-behind, you can use it with Response.write in the HTML




html:

<div><%=YourString%></div>


code:

Partial Class yourpage
    Inherits System.Web.UI.Page
    
    Public YourString As String = "test"
    
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        YourString = "pageloaded"
    	
    End Sub

End Class

Open in new window

0
 

Expert Comment

by:sundara2010
ID: 33690752
can you use the literal control . use into code behind
 put like that  Literal1.text="Image edit"

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

626 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