tgreer 189 Made Her Cry Team Colleague

Just to throw this out there: many of those "Get a Free Whatever" promotions are actually legitimate, if you want to go through the hassle. They require, usually, that you purchase 2 or 3 items from several pages of offers. Once you've completed these transactions, you enter a waiting period, until they "come through". Then you enter another waiting period, completely arbitrary, until you are "confirmed". Then there is some paperwork. Finally, sometimes a few months later, you get the product or its near equivalent.

Plus, you're saddled with whatever you bought. The key is to buy something you'll really use (like Blockbuster online), or something that you're willing to cancel, with all of that attendant hassle: vitamin samples or weight loss patches, etc. that only cost a few dollars but enroll you in a monthly program unless you cancel within 30 days.

How do I know? I'm closely related to a person with the time and inclination to go through that hassle. The freebies thus garnered include a Sony Aquas LCD TV, a PSP, an ACER Laptop, and an IPOD 60GB.

tgreer 189 Made Her Cry Team Colleague

They seem to be working, for me, in FireFox. When I rollover, the black border turns red.

To answer your question, though, give all images the same class, with the CSS looking something like this:

.myImages {border:1px; border-thickness: 1px; border-color: #000; border-style: solid;}

Then, you can use CSS to cascade that definition to hyperlinks:

a:hover, a:active {color: #fff;}

a:hover .myImages,
a:active .myImages {border:1px; border-thickness: 1px; border-color: #fff; border-style: solid;}

Now, the border of your image links will turn red on hover or active.

tgreer 189 Made Her Cry Team Colleague

Page refreshing would be a client-side issue. You'd use JavaScript for that.

tgreer 189 Made Her Cry Team Colleague

The same thing happened to me. I played with some others, such as ContextWeb and Clicksor. They didn't generate much revenue and were never really "context" appropriate. After much thinking, I've come to the conclusion that Google Adsense is ruining the web, and have decided not to run any "context" ads on my sites - only direct sponsors. I also refuse to ever click any Google ads on any site, ever.

tgreer 189 Made Her Cry Team Colleague

I can't understand the question. If you're inside a server-side event method, the user must have posted the form. You are inside of a "Postback". Also, a postback occurs when the client submits the form back to the ASP.NET application. Even if you could "raise a postback" while running a server-side method, what would that mean?

Either one or both of us is thoroughly confused :).

Could you restate in English (no code) what it is you're attempting?

tgreer 189 Made Her Cry Team Colleague

IE has a "selection" object: http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_selection.asp

However, ASP.NET is such a completely different animal from standard web development, you should ask in the ASP.NET Forum.

This is one of those things that different browsers handle differently, so a seach on "quirksmode.org" is beneficial: http://www.quirksmode.org/js/selected.html

tgreer 189 Made Her Cry Team Colleague

Here's my first attempt, for any following along:

using System;
using System.IO;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;

namespace tgreer
{
	[XmlRoot("indexer")]
	public class indexer
	{
		[XmlElement("documents")]
		private Dictionary<string, Int32> _documents;

		[XmlElement("pages")]
		private Dictionary<string, Int32> _pages;
		
		public indexer()
		{
			// class constructor
			_documents = new Dictionary<string, Int32>(250);
			_pages = new Dictionary<string, Int32>(1000);
		}
		public void addDocIndex(string _seq, Int32 _offset)
		{
			_documents.Add(_seq, _offset);
			
		}

		public void addPageIndex(string _seq, Int32 _offset)
		{
			_pages.Add(_seq, _offset);

		}

		public void serializeMe()
		{
			// Serialization
			XmlSerializer s = new XmlSerializer(this.GetType());
			TextWriter w = new StreamWriter(@"c:\index.xml");
			s.Serialize(w, this);
			w.Close();
		}
	}
}

It works, insofar as it creates an XML file. However, the dictionaries are not contained within it. Obviously I was hoping that two elements would be created, with child elements automatically generated for the key-value pairs within each dictionary. That'd be nice, I guess, but too much to hope for.

So I'll have to beef up the SerializeMe method to iterate through each dictionary, create XML elements/attributes within the loop.

tgreer 189 Made Her Cry Team Colleague

How would I go about making this entire class Serializable?

What code would I add to a second constructor that would restore state/values from the XML file (de-serialize)?

using System;
using System.Collections.Generic;
using System.Text;

namespace tgreer
{
	public class indexer
	{
		private Dictionary<string, Int32> _documents;
		private Dictionary<string, Int32> _pages;
		
		public indexer()
		{
			// class constructor
			_documents = new Dictionary<string, Int32>(250);
			_pages = new Dictionary<string, Int32>(1000);
		}

		public void addDocIndex(string _seq, Int32 _offset)
		{
			_documents.Add(_seq, _offset);
			
		}

		public void addPageIndex(string _seq, Int32 _offset)
		{
			_pages.Add(_seq, _offset);

		}
	}
}

There are just two private dictionaries. The application which uses this class library will add values to the dictionaries by calling the public methods. I need a way to persist any values of a particular instance of this class/object, and to potentially restore them if the proper constructor is called.

tgreer 189 Made Her Cry Team Colleague

It "escapes" certain characters. You need to look at the "addslashes" procedure to get a complete picture.

tgreer 189 Made Her Cry Team Colleague

Hmm... never seen anything like that, sorry. It would require an email client that ran JavaScript.

What I have seen and used is a web application that generated an image, dynamically, on the fly. In your email, you set the src of an image to that application, with parameters. That way you can track that the email was opened, plus generate an image unique to that individual.

Welcome to Daniweb!

tgreer 189 Made Her Cry Team Colleague

Just so this thread doesn't make me look like a complete dope...

The class will be used in another application. That application parses a configuration file. That config file contains the name of the property to set, followed by an expression telling it how to find the value.

So, I had to use reflection anyway to turn the name of the field, from the config file, into the actual property to set. I just didn't need to use reflection in the class itself.

tgreer 189 Made Her Cry Team Colleague

Well, given that at least 2 seasoned Web Developers with likely over 30+ years combined experience have never even heard of the term, I would say the exam is screwy. Even the term "Universal Resource Name" is a bit off. There are URIs and URLs, (Universal Resource Indicators & Universal Resource Locators), but not URNs.

If you are revising the exam, just strike that question entirely.

Also, be careful what you end sentences, err,... with.

tgreer 189 Made Her Cry Team Colleague

That's what I said: "mailto" is an instruction to the client's email program. Thus, it is relying on machine-specific configurations. The proper way to email form data is to use a server-side email script.

tgreer 189 Made Her Cry Team Colleague

The action tag is used to tell the browser which web server application will process the form data. The "mailto:" is used for hyperlinking to a client's email client. Combining them is... not going to work.

You need to use a server-side email script, in whatever language you use for server-side development.

tgreer 189 Made Her Cry Team Colleague

If this is a large enough concern, contact law enforcement. Trying to play "internet investigator" on your own is a fruitless and frustrating task. Turn over what you've discovered to the police, and they can determine if a crime has been committed or if anyone is in imminent danger, and they'll have the resources to pursue the matter properly.

tgreer 189 Made Her Cry Team Colleague

As has been mentioned, a string IS an array, of characters. You can use it like an array already, so there isn't really a need to convert it explicity. Perhaps if we knew what you were trying to do, we could give better advice.

tgreer 189 Made Her Cry Team Colleague

Technically, it would be: (sorry, not even vBulletin will display it).

Ampersand-Pound-Zero-Nine-Semicolon

However, it has no relevance inside HTML, as HTML treats all whitespace characters the same, with the exception of the non-breaking space.

If you wish to align elements, use CSS or tables.

tgreer 189 Made Her Cry Team Colleague

No, I've never heard that term.

tgreer 189 Made Her Cry Team Colleague

Because Viewstate is scoped to that particular "instance" of that particular page. It has no relevance whatsoever to another page within that application. If you need to maintain some value across the application, you'd use the Session object instead.

I explain ViewState here: http://www.tgreer.com/aspnet_html_02.html

I explore ViewState, Session, the ASP.NET Page Life Cycle, and conditional dynamic controls in this article: http://www.tgreer.com/aspnet_html_04.html

tgreer 189 Made Her Cry Team Colleague

I think an IFRAME would be your only choice.

tgreer 189 Made Her Cry Team Colleague

Also... Viewstate does not store the "vaules of... controls". The HTTP Request mechanism does that.

Well, that's almost right. Let's say that Viewstate does not store the value of Form Elements. What it does is store the "state" of any controls that have had their attributes altered server-side. For example say you use an ASP.NET Label control, with an initial setting. In response to some event, you change the value of that Label. The Viewstate mechanism would be used to transport that new value to the client.

tgreer 189 Made Her Cry Team Colleague

Viewstate "lives" in a hidden variable embedded within the form. Thus, it is resident client-side. While the user is looking at the page, the ASP.NET application isn't "running". Thus, Viewstate doesn't exist at all.

When the users posts the form, IIS/ASP.NET go through a series of steps, one of them being the re-building of the state-bag (ViewState) from the HTTP Request object (remember, Viewstate is a hidden form variable, so is posted in the Request).

The Page Life-Cycle goes on, eventually calling any event handlers, and building the Response. This includes re-packaging the NEW Viewstate into the hidden variable. The Response is shipped back to the client, and your application goes back into non-existence until the user posts again.

Thus, ViewState only "lives" as long as it takes your application to generate a Response.

tgreer 189 Made Her Cry Team Colleague

DW is Dreamweaver? I've never used it, so don't know. The SnippetEdit demo should answer all your questions. But, the way it works is that you add "<snippet> </snippet>" tags around whatever content you wish to edit. Browsers/users of your site will never see them.

You, however, as the administrator, do. It doesn't matter how the text or images are displayed (HTML, PHP, whatever), as you are only editting the CONTENT, inside your browser, with a WYSIWYG editor. Run the demo, you'll understand.

The developer, I must say, is a friend of mine. He's also a member of Daniweb and moderates the PHP forum here.

tgreer 189 Made Her Cry Team Colleague

Ok, I think I'm understanding now.

The way to create a page with two separate "content sections" is to arrange the content into separate block-level elements.

You can do this with a TABLE, or with DIV elements.

A DIV looks like:

<div id="leftSide">
Place whatever HTML you want here, 
including scripts that generate content.
</div>

<div id="rightSide">
Place whatever HTML you want here, 
including scripts that generate content.
</div>

Normally, the second DIV would display below the first DIV. You can change this behavior with CSS. The CSS attribute you'd use would be "float".

Here is a complete, though very simplistic, example:

<html>
<head>
<style type="text/css">
.left
{
  float:left;
  width:250px;
}
.right
{
  float:right;
  width:250px;
}
</style>
</head>

<body>


<div id="leftSide" class="left">
Place whatever HTML you want here, 
including scripts that generate content.
</div>

<div id="rightSide" class="right">
Place whatever HTML you want here, 
including scripts that generate content.
</div>

</body>
</html>

You should tinker with this, look up the CSS "float" attributes, understand what they do, as well as the other CSS properties (such as "width"). Learn the difference between CSS "class" definitions and "id" definitions.

tgreer 189 Made Her Cry Team Colleague

You still haven't given us enough information to give you a meaningful answer.

You can add content to your web pages by writing HTML. You can position that content, to the left, or the right, with CSS.

What content do you want to add? How? Where? When? I just don't understand what you're asking.

tgreer 189 Made Her Cry Team Colleague

Your question isn't very clear. What is it that you wish to edit? For a good general-purpose text-editor, I like TextPad.

If you want a way to edit your web pages, in order to periodically tweak the content, I suggest "SnippetEdit". It's an editor that allows you to modify your pages, directly within your browser, in a WYSIWIG fashion: http://www.snippetedit.com

tgreer 189 Made Her Cry Team Colleague

Your question, as asked, is impossible to answer. You've left us too much to guess. What kind of script? What kind of content? Is this a CSS question relating to placement of HTML elements? Margins? Padding? Centering? Or are you asking for suggestions as to what kind of generic content you could place on your site? What does "make up it" mean?

tgreer 189 Made Her Cry Team Colleague

The best way is to author a JavaScript that does so. You don't want a complete server roundtrip just to open a window!

You can add scripts via "RegisterStartupScript" method of the Page object.

tgreer 189 Made Her Cry Team Colleague

Wow, is this a "too much information" topic, or what?? Do you really want to know that I'm a hairy, hairy man, so must shave twice a day, and has the habit of only shaving in the shower? What's next, the "how often do you cut your toenails" poll?

tgreer 189 Made Her Cry Team Colleague

Thanks for the gracious answer... I thought my last post came across too strong. My point was, ASP.NET is a profoundly different web development methodology (profoundly flawed, in my opinion).

Thus web developers who understand the client-server nature of the web, the stateless environment, etc. who then try to switch to ASP.NET, which "pretends" that you're developing on a fat client with state, will have a very difficult time.

We get tripped on on KNOWING how the web works, what the client does with scripts, cookies, and the retinue of HTML Form elements and CSS. ASP.NET hides all of that from the developer, so we end up fighting it all the way. Your scenario was a perfect example: you wanted to create some HTML elements, client-side, with JavaScript. You then wanted to get those values, server-side. Simple, in ASP or PHP - mind-numbingly awkward in ASP.NET.

red_evolve commented: :) +4
tgreer 189 Made Her Cry Team Colleague

That looks like valid RSS, so however you created it, you did it correctly. If on the other hand, you are asking how to consume that RSS feed to display content on your site, you'll need to write some code in whatever server-side language you use to parse the XML into whatever you like (HTML, presumably). So you should ask your question in either the ASP, PHP, or ASP.NET Forum.

I don't use Dreamweaver, but doubt it has any way of authoring an RSS consumer.

tgreer 189 Made Her Cry Team Colleague

Use the "submit" method of the Form object. You should always give your form an ID:

<form id="myForm" action="myServerSideCode.php" method="post"></form>

Then, you can reference and submit the form with a script that looks like:

document.getElementById("myForm").submit();
tgreer 189 Made Her Cry Team Colleague

All form values are submitted back to the server, so all form values are in the Request object, multi-select or not.

Of course, the canonical way to do this in ASP.NET is to populate your controls server-side, even if this means adding server round-trips to your logic.

Glad you got it working, but I predict you're going to have a real struggle with ASP.NET!

tgreer 189 Made Her Cry Team Colleague

Doh!

For some reason I had convinced myself that I'd need to use Reflection... because I'd have to set only those properties that represent fields to space-filled strings, but not any other public properties. Somehow "Reflection" popped into my head, and prevented me from seeing the obvious: only set the properties you actually need to set...

I'm still using the Dictionary, so that the field lengths are only coded in one spot. The Contructor and the Public "setter" proc can both reference the Dictionary.

Thanks for your help.

tgreer 189 Made Her Cry Team Colleague

The public properties looks like this:

private string _field1;
public string Field1
{
  get { return _field1; }
  set
  {
	 _size = -1 * _fieldLengths["Field1"];
	 _format = "{0," + _size.ToString() + "}";
	 _field1 = String.Format(_format, value);
  }
}

Works great.

tgreer 189 Made Her Cry Team Colleague

Yes, it did. I can use that as I code the "get" procedures for each of the public properties, thanks.

Here's my solution so far. I'd like commments on this approach. Am I dramatically overcomplicating the issue? The goal again is for the class constructor to initiliaze certain public properties, filling them a certain amount of spaces.

The names of the properties, as well as the required "size" and/or length, are contained in a Dictionary.

If there is a more efficient and clear (self-documenting) way of doing this, I'd like to hear about it.

using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace TGREER
{
    public class GenericIO
    {
        // first all private/public fields
        
        private string _field1 = "";
        public string Field1
        {
            get { return _field1; }
            set { _field1 = value; }
        }
        private string _field2 = "";
        public string Field2
        {
            get { return _field2; }
            set { _field2 = value; }
        }
        private string _field3 = "";
        public string Field3
        {
            get { return _field3; }
            set { _field3 = value; }
        }

        StringBuilder workString = new StringBuilder();
        private Dictionary<string, int> _fieldLengths = new Dictionary<string, int>(3);

        public GenericIO()
        {
            // class constructor
            _fieldLengths.Add("Field1", 20);
            _fieldLengths.Add("Field2", 5);
            _fieldLengths.Add("Field3", 10);

            // use Reflection to use the strings in the Dictionary to retrieve the actual string object
            Type MyType = this.GetType();

            workString.Append(" ");

            foreach (KeyValuePair<string, int> kvp in _fieldLengths)
            {
                workString.Remove(0, workString.Length);
                workString.Insert(0, " ", kvp.Value);
                PropertyInfo Mypropertyinfo = MyType.GetProperty(kvp.Key.ToString());
                Mypropertyinfo.SetValue(this, workString.ToString(), null);
            }
        } …
tgreer 189 Made Her Cry Team Colleague

Not quite. Something like this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace tgreer
{
	public class GenericIO
	{
		 private string _field1;  // 20 bytes
		 private string _field2;  // 5 bytes
		 private string _field3;  // 10 bytes

		 private Dictionary<string, int> _fieldLengths = new Dictionary<string, int>(3);

		public GenericIO()
		{
			// class constructor
			_fieldLengths.Add("_field1", 20);
			_fieldLengths.Add("_field2", 5);
			_fieldLengths.Add("_field3", 10);

			Type _myTypeObject = Type.GetType("GenericIO");
			MemberInfo[] _myMemberArray = _myTypeObject.GetMembers();

			foreach (KeyValuePair<string, int> kvp in _fieldLengths)
			{
				// this loop "initializes" each field with the proper number of spaces
			  
			}


		}
	}
}

I'm not done, of course, coding the foreach loop. The constructor uses Reflection on itself, so that it can use the strings in the Dictionary (basically, an optimized 2-dimensional array), to actually get the correpsonding string and set its value.

I need a way to pass a string "field1" to get the string variable field1, and that's accomplished with reflection. Then I'll use PadRight to fill the string with the number of spaces it requires.

Yeah, I'm probably overcomplicating this... thanks for the discussion, though.

tgreer 189 Made Her Cry Team Colleague

I don't like that approach because it isn't self-documenting. Hard-coding the spaces would work, but another programmer could come along, not understand the reason for the spaces, and delete them. Or even just one of the spaces, accidentally, introducing a hard to find error.

What I've done: make a private string for each field. Make a private dictionary with the fieldnames as keys, the lengths as values. The class constructor will use a foreach to get each kvp (key-value-pair), and then "fill" the string using the .PadRight method.

Next, create the public strings and code the get/set, with the "set" procedure doing error-checking and proper padding of shorter values.

tgreer 189 Made Her Cry Team Colleague

That's precisely what I hoped to avoid: a loop-based method of padding out strings.

I think I'll use a Dictionary (.NET Framework 2.0) to hold field names-to-lengths. I can create space-filled strings for each field/property in the constructor. Then when a value is passed into a particular field, I'll need a quick, efficient way to "insert" the value, leaving any trailing spaces. I definitely do NOT want a loop.

tgreer 189 Made Her Cry Team Colleague

For one of my customers, I have to develop applications that communicate with each other via fixed-width files. In other words, they have developed a file format that is "generic" to a lot of operations. If I write a new utility, it is expected that the utility will be able to read, write, and parse this generic file. The file is fixed-width, with each field taking up a "hard-coded' number of bytes.

Of course I'll write a reusable class to handle the file i/o. My question is, what is the best approach to handling fixed-width fields?

Each field will have to be a property. All data is essentially string data. I could define a string per field, but how do I force the strings to be a specific length? All strings will be right-padded with spaces...

For example, there is a 20-byte "account number" field. It starts at byte 56 in the record, and always takes up 20-bytes in the record. If I pass in a 12-byte value, the string should hold 12 bytes followed by 8 spaces.

In C#, you cannot "DIM" a string to a pre-defined length, can you?

Should I use StringBuilder to dynamically build the record, appending the fields/string, then appending spaces equal to the required length of the field minus the actual length of the string?

Is there an elegant way to store the field names/lengths?

I'm envisioning a class called "GenericIO", with the fields as properties:

tgreer 189 Made Her Cry Team Colleague

Some of these descriptions of HTML are a bit off. It is exact, there is an exact definition/specification for each HTML version. It isn't precisely about "displaying information". It is a structure for a document, true. But the specific manner in which that document is display is not a part of HTML. That's up to the browser, and CSS.

tgreer 189 Made Her Cry Team Colleague

Elements you add via JavaScript have nothing to do with Objects created in ASP.NET. Given the client-server nature of the web, surely you can see why this is the case.

Server Objects (ASP.NET "Web Controls") exist only on the server. When done processing, the ViewState object is created and embedded within the response stream as a hidden form variable. This is the mechanism by which Web Controls are recreated and restored to their state on PostBack.

Since your JavaScript is creating client elements, and not adding them to the ViewState variable, there is no way your server-side control can create corresponding Web Controls on postback.

What you need to do:

Server-side, you can iterate through the Request object to retrieve posted form values, including any options etc. you created client-side.

OR

Create all your controls server-side.

tgreer 189 Made Her Cry Team Colleague

1) Try using .FindControl.

2) Nope. The only thing JavaScript can do in relation to ASP.NET is submit the form. ASP.NET functions don't even exist until the form is submitted.

tgreer 189 Made Her Cry Team Colleague

Here's a basic breakdown:

http://www.tgreer.com/cssPOS.html

tgreer 189 Made Her Cry Team Colleague

I see. Ok, that needs to be asked in the appropriate server-side forum, doesn't it? You can't perform an email operation in client-side code.

tgreer 189 Made Her Cry Team Colleague

I'm unclear what it is you're asking. You want to send some HTML code to a friend? Please clarify!

Also, since this is a professional forum, we expect a professional style of speech/language. Please strive to use proper punctuation and conventional spelling - one shouldn't have to decipher your messages or guess at what you're asking.

tgreer 189 Made Her Cry Team Colleague

The header on the technical articles pages themselves, not the index to the articles. For example:

http://www.tgreer.com/aspnet_html_04.html

Click in the white/gray header area.

tgreer 189 Made Her Cry Team Colleague

You mean DHTML, I think, rather than "AJAX". There are entire sets of objects and methods for drag/drop in HTML/Javascript/CSS (which is what "DHTML" means, essentially).

AJAX, on the other hand, involves using the XHTTP Request Object to give the appearance of dynamic-content sans server-roundtrip.

On my own site, for example, if you click one of the technical articles, you'll see a graphic header with my logo. Click it, and a "popup" DIV appears, which is draggable/positionable. That's done with DHTML, not AJAX.

tgreer 189 Made Her Cry Team Colleague

Hi, welcome! Since this is a professional forum, we highly suggest members use correct punctuation and spelling rather than the "Instant Messaging" style of text. We have many other members from India; I'm sure you'll find this a very nice community.

tgreer 189 Made Her Cry Team Colleague

This isn't really an introduction, is it? Oh well: I suggest "quizzle".