Server-side html coding

VS does not allow me to type in <script etc

Page 1 of 1

7 Replies - 958 Views - Last Post: 19 March 2009 - 06:53 PM

#1 RalphGarner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 17-March 09

Server-side html coding

Post icon  Posted 17 March 2009 - 11:53 AM

What to change color of label in Web Form by letting each user click a button. Cannot figure out how to put code in aspx.vb without geting a souce code error. Is there an option in Visual Studio 2003 that allow you to key html in aspx.vb.
Be kind, I know this is an easy question.
Thanks.
Is This A Good Question/Topic? 0
  • +

Replies To: Server-side html coding

#2 adamn.davis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 11-March 09

Re: Server-side html coding

Posted 17 March 2009 - 04:14 PM

View PostRalphGarner, on 17 Mar, 2009 - 10:53 AM, said:

What to change color of label in Web Form by letting each user click a button. Cannot figure out how to put code in aspx.vb without geting a souce code error. Is there an option in Visual Studio 2003 that allow you to key html in aspx.vb.
Be kind, I know this is an easy question.
Thanks.


Should be fairly simple, yes ?
in VS you can simply drag and drop to create a label and do the same to create a command button. Then, you should be able to double click on a command button to open the procedure to fire when you click on the button. You'll want to put code there. Changing the color of a label should be as simple as Label.BackColor or Label1.forecolor = [color]..

What error are you getting? what code are you running? Posting more details will probably help. :|
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6064
  • View blog
  • Posts: 23,519
  • Joined: 23-August 08

Re: Server-side html coding

Posted 18 March 2009 - 02:59 AM

Moving to ASP.NET.
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Server-side html coding

Posted 18 March 2009 - 03:42 AM

the code and the errors would be helpful.
Was This Post Helpful? 0
  • +
  • -

#5 RalphGarner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 17-March 09

Re: Server-side html coding

Posted 18 March 2009 - 12:21 PM

View Postadamn.davis, on 17 Mar, 2009 - 03:14 PM, said:

View PostRalphGarner, on 17 Mar, 2009 - 10:53 AM, said:

What to change color of label in Web Form by letting each user click a button. Cannot figure out how to put code in aspx.vb without geting a souce code error. Is there an option in Visual Studio 2003 that allow you to key html in aspx.vb.
Be kind, I know this is an easy question.
Thanks.


Should be fairly simple, yes ?
in VS you can simply drag and drop to create a label and do the same to create a command button. Then, you should be able to double click on a command button to open the procedure to fire when you click on the button. You'll want to put code there. Changing the color of a label should be as simple as Label.BackColor or Label1.forecolor = [color]..

What error are you getting? what code are you running? Posting more details will probably help. :|



I understand exactly what you are saying. And you are correct. However, more specifically I want to change a single word in a label to a color. VB.Net does not let you do this. Therefore, I need to use HTML (Javascript/VBScript) to do this. But I am not sure where to put the code: Should I use:
1. Response.Write... or
2. HTML module or
3. Put HTML in apsx.vb (some somewhere). However, when I use <?-- or <!--, these codes, which I understand should surround HTML code in aspx.vb, are flag by the editor as errors before I can get off the ground. I hope this is clear.
Thanks
Was This Post Helpful? 0
  • +
  • -

#6 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Server-side html coding

Posted 18 March 2009 - 01:02 PM

View PostRalphGarner, on 18 Mar, 2009 - 02:21 PM, said:

View Postadamn.davis, on 17 Mar, 2009 - 03:14 PM, said:

View PostRalphGarner, on 17 Mar, 2009 - 10:53 AM, said:

What to change color of label in Web Form by letting each user click a button. Cannot figure out how to put code in aspx.vb without geting a souce code error. Is there an option in Visual Studio 2003 that allow you to key html in aspx.vb.
Be kind, I know this is an easy question.
Thanks.


Should be fairly simple, yes ?
in VS you can simply drag and drop to create a label and do the same to create a command button. Then, you should be able to double click on a command button to open the procedure to fire when you click on the button. You'll want to put code there. Changing the color of a label should be as simple as Label.BackColor or Label1.forecolor = [color]..

What error are you getting? what code are you running? Posting more details will probably help. :|



I understand exactly what you are saying. And you are correct. However, more specifically I want to change a single word in a label to a color. VB.Net does not let you do this. Therefore, I need to use HTML (Javascript/VBScript) to do this. But I am not sure where to put the code: Should I use:
1. Response.Write... or
2. HTML module or
3. Put HTML in apsx.vb (some somewhere). However, when I use <?-- or <!--, these codes, which I understand should surround HTML code in aspx.vb, are flag by the editor as errors before I can get off the ground. I hope this is clear.
Thanks


This is one way you add javascript to an ASP.Net page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication3._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
	<title></title>
		<script type="text/javascript" language="javascript">
			function SetLoading(btnName) {
				// Some code
			}
		</script>
</head>
<body>
	<form id="form1" runat="server">
	
	</form>
</body>
</html>


Was This Post Helpful? 0
  • +
  • -

#7 adamn.davis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 11-March 09

Re: Server-side html coding

Posted 18 March 2009 - 08:44 PM

Oh.. Hmmm... Well, as far as I know, HTML code doesn't know in the Code behind page. Not the .ASPX.VB page. You can put HTML and the like in the .ASPX page. I know I've put HTML (hand-written) in a .ASPX page, but I'm not 100% about the code you speak of. You could also simply build the code in a Code Behind procedure/sub. Simply have a large control, I think you would want a Literal for that ? or maybe just a Label. But either way, you should be able to build the HTML within the Code-Behind procedure/sub.
lblExample.text ="<br />Hey, this last word should be <font color=blue>Blue</font>"


I think? :| Lol
Was This Post Helpful? 0
  • +
  • -

#8 wydok  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 16-March 09

Re: Server-side html coding

Posted 19 March 2009 - 06:53 PM

I never like using ASP.NET for something I can simply do in Javascript. Why waste the round trip to the web server?

So, in Javascript, there is a replace() function that can replace text.

But if you absolutely must use ASP.NET, you can still do what adamn.davis suggested.

1. Create an asp:textbox

2. Create an asp:commandbutton

3. On the code-behind for the button, get the value from the textbox and use the String.Replace() method to replace whatever you are looking for with "<span style="color:(YOURCOLORHERE">(YOURTEXTHERE)</span>"

This post has been edited by wydok: 19 March 2009 - 06:54 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1