tgreer 189 Made Her Cry Team Colleague

Frames contain content. If the content doesn't fit inside the frame, then the content will be truncated. There isn't a way to "fix" that, since nothing is really broken. Frames are frames, and that's how they behave.

There is nothing magical about DIVs, they are simply organizational block elements. The idea is to break your page into sections, and code each section into a DIV. Your menu would go in one DIV, your left-hand panel into a second, and your main page content in a third. Use CSS to control the position and style of each DIV.

tgreer 189 Made Her Cry Team Colleague

Congrats!

The margin statement should be:

margin: 0 auto;

As that sets the top margin to 0, and the left/right to "auto", which centers the control, relative to any containing elements.

So my point is, "margin: 0 auto" is the proper way to center things in CSS, and if things aren't centering, look to see how you're nesting your controls.

tgreer 189 Made Her Cry Team Colleague

This forum is for technical questions. I think the "site development" forum will get you more and better responses, therefor I'm moving your thread there.

tgreer 189 Made Her Cry Team Colleague

No, I don't think I'll post any "real code". You're undertaking a sizable project, and that's a bit beyond the scope of coding for a forum example.

Quite simply, you have to duplicate the entire "open file dialog" box of the Win32 API. Such a thing just doesn't exist on the web. Web servers aren't built for this task. You'll have to code the entire graphic form, somehow using Web Server Controls... then populate the controls with the directory and file information. Then code all the events for when a user clicks a file or folder, each of which will require a server round-trip.

It's a big, big project. I think you'd be much better off making your project conform to the way the web works: give your users a list of hyperlinks.

tgreer 189 Made Her Cry Team Colleague

ASP.NET or Windows Forms, it doesn't matter. Anything in the .NET Framework can be imported. It's a way of aliasing a namespace. You do it at the top of your program:

C#

using System.IO;

VB.NET

Imports System.IO
tgreer 189 Made Her Cry Team Colleague

You can do this with a Server Side Include (SSI). The syntax depends upon what server you are running. Is the site run with ISS, Apache? Does the server support PHP, ASP, or what?

A purely "client-side" technique is to write the content of that section of each page via a JavaScript, using document.write(). Include that JavaScript on every page.

tgreer 189 Made Her Cry Team Colleague

Sure. The original 3 dots I've colored blue. Each new dot is formed by connecting two other dots. I've numbered the dots in sequence, so you can see how I drew the lines. The 8th dot ends the game. Whoever drew the 8th dot is the winner, since it's the last dot. Why is it last? Because there are no other "open" dots to which it could connect. You can see that all dots have 3 lines except the 8th.

8 moves, 11 dots.

[IMG]http://www.brownfedora.com/dot_game.gif[/IMG]

tgreer 189 Made Her Cry Team Colleague

You can let the user browse their LOCAL file system, and select a file to upload, via the <input type="file"> HTML tag. There is no equivalent to let a user browse the server's file system.

I understood your question. My answer was meant to show you that you'll have to code this yourself, and some of the .NET classes you could use to do so.

Left unstated is what the user would do with a file they selected. To know what they selected, you'll have to generate a PostBack / form submit, and then presumably serve them back the selected file via a Response.Redirect() to that file.

tgreer 189 Made Her Cry Team Colleague

At my various jobs, I've always introduced what I call the "dot game" to my team. Start by placing three dots on a whiteboard (or paper, of course).

Draw a line between any two dots. Place a new dot anywhere on the line.

A dot can only have three lines touching it. (Explanation: start with just two dots. Draw a line between them. Each dot now has one line. Draw your new dot on the line. That new dot is touched by TWO lines. The new dot in effect cuts the one line in two. The new 3rd dot can only have one more line drawn to/from it.)

No line can intersect another.

You can draw a line out from and back to the same dot in a little loop, realize though that the dot would be touched TWICE if you do.

Lines can wrap AROUND a dot, encircling it. That's important, since no lines can intersect.

To help me with game strategy, I've looked at the math and realized that:

Max_Possible_Dots = (Starting_Dots * 4) - 1

My challenge to the group is to explain why that equation works.

(If you know how many dots are possible, you know if you want to play first or last. Knowing that, you can try to eliminate potential dots by limiting all possible moves, somehow.)

tgreer 189 Made Her Cry Team Colleague

I'm sorry I wasn't more clear. The function you need to call is "print()". So just change your tag to :

<input TYPE="button" VALUE="Print" onClick="window.print();">

When the user clicks the button, the print dialog box will appear.

tgreer 189 Made Her Cry Team Colleague

It's just "print()".

You can get PHP hosting affordably. Lots of options. I use a company called "ShinySolutions": http://www.shinysolutions.com

tgreer 189 Made Her Cry Team Colleague

Another little snag: how does one dynamically declare an object to be of a certain type?

In other words, MethodInfo.ReturnType tells you the defined return type of the method. So how do you declare a return object/variable of that type?

tgreer 189 Made Her Cry Team Colleague

On the other hand, this code works fine:

Type myType = typeof(Class1);
				MethodInfo myMethodInfo = myType.GetMethod(function);
				ParameterInfo[] myParameters = myMethodInfo.GetParameters();
				
				// collect parameters, call method.
				object[] methodParams = new Object [myParameters.Length];
				int mpIndex = 0;
				foreach( ParameterInfo paramInfo in myParameters)
				{
					if (paramInfo.ParameterType == Type.GetType("System.IO.FileStream"))
					{
						methodParams[mpIndex] = baseFS;
					}

					mpIndex++;
				}

				object retval = myType.GetMethod(function).Invoke(null, methodParams);

The question is, "why?". The invoke method calls for two parameters, object, and the method parameters, as an object array.

I've passed in "null" as the object, because there is NOT an instance object. All methods are static. The only instance is the currently running program. Is "null" correct, then, or is there a proper way to refer to the currently running program?

tgreer 189 Made Her Cry Team Colleague

Why does it always seem that when I post C# threads, I'm only talking to myself? In any case, I've hit my first snag. I've reached the point where I want to invoke a public, static method that's defined in the current class. All the System.Reflection examples I've found are for invoking methods from a different class, or an assembly, or on instance objects. How do you invoke a STATIC (ie, "class method") method of the CURRENT class?

Code:

using System;
using System.IO;
using System.Collections;
using System.Reflection;

namespace pcl_util
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		static string filename;
		static string function;
		static FileStream baseFS;


		[STAThread]
		static void Main(string[] args)
		{
			// get filename to process, if found, declare a FileStream
			filename = args[0].ToString();
			if (File.Exists(filename))
			{
				baseFS = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read, 8192);
			}
			else
			{
				Console.WriteLine("FILE NOT FOUND: " + filename);
			}

			// does function exist in this program? If so, get its parameters and run it
			function = args[1].ToString();
			if (checkFunction(function))
			{
				Type myType = typeof(Class1);
				MethodInfo myMethodInfo = myType.GetMethod(function);
				ParameterInfo[] myParameters = myMethodInfo.GetParameters();
				
				// collect parameters, call method.
				object[] methodParams = new Object [myParameters.Length];
				int mpIndex = 0;
				foreach( ParameterInfo paramInfo in myParameters)
				{
					if (paramInfo.ParameterType == Type.GetType("System.IO.FileStream"))
					{
						methodParams[mpIndex] = baseFS;
					}

					mpIndex++;
				}

				myType.InvokeMember(function,
					BindingFlags.DeclaredOnly |
					BindingFlags.Public |
					BindingFlags.InvokeMethod, null, null, methodParams);

			}
			else
			{
				Console.WriteLine("FUNCTION NOT FOUND: " + function);
			}
	}

		public static bool checkFunction(string f)
		{
			Type myType = typeof(Class1);
			MethodInfo myMethodInfo …
tgreer 189 Made Her Cry Team Colleague

It looks like the System.Reflection class has everything I might need. As this develops, I'll post code. I'd still like any input anyone has to offer.

tgreer 189 Made Her Cry Team Colleague

On the server side, you'd use Server.MapPath to specify the viritual path to your directory. Then perhaps DirectoryInfo.GetFiles to return a filelist. Iterate through that list to populate whatever Server Control you want to contain that data. A Repeater, perhaps.

tgreer 189 Made Her Cry Team Colleague

You return a SqlDataReader as the result of the .ExecuteReader() method of the Command object:

SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection);
 myConnection.Open();
SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(myReader.Read()) 
{
    Console.WriteLine(myReader.GetString(0));
}
myReader.Close();
//Implicitly closes the connection because CommandBehavior.CloseConnection was specified.
tgreer 189 Made Her Cry Team Colleague

Can you use the "RegisterClientScriptBlock()" method, instead?

tgreer 189 Made Her Cry Team Colleague

I'm writing a utility program. In fact, the program will be a Console application that will contain many static methods, each method being a specific utility.

The application will take two command line arguments: filename, and utility name. Of course I want to run the method specified on the file specified.

I want to discuss approaches to this. Each method may have a unique signature and return value/type.

Thinking through this, I need a way to

1) check to see if the method on the commandline exists in the program. I could create an array of all method names, and check against the array. Simple enough, but is there a more elegant way? Does a class contain knowledge of its own members?

2) invoke any particular method, given a string. That string would be the method name.

How would I know what parameters I need to pass to the method? They wouldn't come from the commandline. I need some way of knowing, gathering, and passing in all required parameters/objects.

What I'm thinking is that the Main() method will declare a FileStream, plus any other objects that may be needed by any of the utility methods. I need some way to "map" these objects to the parameters needed by the method I want to call.

Again, I could create some data structure that said "if arg[1] equals this string, then call this method with these parameters". The problem is that becomes more to …

tgreer 189 Made Her Cry Team Colleague

Ok, well, then ignoring all the details about web and shared folders, we'll focus just on StreamReader.

1. Import the correct namespace, which in this case would be: System.IO

2. Define the StreamReader. You can define in combination with its constructor. In C#, for example:

StreamReader sr = new StreamReader("TestFile.txt");

3. Read from it, into a string:

string line;

while ((line = sr.ReadLine()) != null) 
{
  //Do Something
}

There are lots of variations. One thing I like to do is first create a FileStream object, and point that to my file. This gives me a lot of control over the access method, whether I want to share the file, and so on.

Then, I use a StreamReader constructor that creates a Streamreader from the FileStream.

Notes: Streamreader is buffered, so it's very fast, but you can often get lost in where you THINK the file is positioned, and where it actually IS positioned.

I'm sure you have more questions, just keep asking within this thread.

tgreer 189 Made Her Cry Team Colleague

So this is a web app then, correct? Then the files should be in a folder accesible to the web app, not the root of your server.

Do you need help using StreamReader, then?

tgreer 189 Made Her Cry Team Colleague

So did adding "margin: auto", fix things for you, or do you still need help?

tgreer 189 Made Her Cry Team Colleague

The quintessential example of CSS menus is the "suckerfish dropdowns". Note that a "dropdown" is equivalent to a "flyout", I think.

If you do a web search for "suckerfish dropdowns", you'll find everything you need. If not, just post questions to this thread and we'll work it out.

tgreer 189 Made Her Cry Team Colleague

No problem! We'll leave the thread, that's the beauty of forums. You never know who else has the same problem and might find the answer here.

tgreer 189 Made Her Cry Team Colleague

What is a "lacation reading"? I find it difficult to visualize your scenario. Can you post a link to the site?

tgreer 189 Made Her Cry Team Colleague

I'm sorry this went unanswered, I hoped someone else would chime in. Without server-side coding, the only suggestion I have is to setup a mail group in your mail server. Your form submits to one email address, and your mail server then distributes to the group.

tgreer 189 Made Her Cry Team Colleague

DIV is "division", and is a block-level container object. It's used to divide a page into discrete, high-level "sections". For example, if you had a navigational section and content section, each would go into its own "div".

SPAN is an inline container object. It is used to set off elements that appear "within" content. It is mainly used to replace the formatting tags such as <b>, <i>, <em>, and <strong>. Since those are presentational tags, they have been superceded by CSS.

The <th> is "Table Header", and is meant for just that... to specify the column headers of a table.

Complete information on all things HTML, XHTML, etc:

http://www.w3.org/TR/REC-html40/struct/global.html

tgreer 189 Made Her Cry Team Colleague

What doctype are you using? Without a doctype, you'll have different behaviors in different browsers.

Try adding "margin: auto;" to your div's inline style declaration.

tgreer 189 Made Her Cry Team Colleague

No, I'm sorry, I wouldn't have a clue. You'll have to ask them, I'm afraid.

tgreer 189 Made Her Cry Team Colleague
tgreer 189 Made Her Cry Team Colleague

ViewState can be very tricky. Try using a Session state variable for this, or, the tried-and-true method of writing a cookie instead.

tgreer 189 Made Her Cry Team Colleague

So... where are these textboxes actually created? Are they WebServer controls, or just HTML "input" fields?

If they are Webserver controls, ask yourself why?

If they aren't, then get the values out of the Response object.

When is "filldata" executed?

tgreer 189 Made Her Cry Team Colleague

That would violate the browser security model. Browsers are not supposed to author files on a user's system.

The exception that has been provided is the cookie mechanism.

Even if you use StringBuilder to build a "file"... what are you going to do with it? You have to render something to the Response stream. I would suggest you write it into a DIV. Let the user select it and save it if they wish.

tgreer 189 Made Her Cry Team Colleague

It should be cross-browser, though I admit I only tested with FireFox. I really don't use IE anymore.

tgreer 189 Made Her Cry Team Colleague

Yes, you're right.

You'll have to use JavaScript. Add this in your document head:

<script type="text/javascript">
//<![CDATA[
onload=function() {
document.getElementById('leftbar').style.height=
document.getElementById('rightbar').style.height=
document.getElementById('maincontent').offsetHeight+"px";
}
//]]>
</script>

This makes the style.height of your two side divs equal to the offsetHeight of your main div. It will run automatically "onload" (you don't have to modify your body tag), and will validate as xhtml (the CDATA comment sees to this).

Of course, you should remove the "height: 700px;" statements from your CSS.

tgreer 189 Made Her Cry Team Colleague

The problem with xhmtl, css, and height, is that percentage heights refer to the percetange of the containing element. The parent element is "body". So, you have to give the body tag a height of 100%, as well as all child tags.

tgreer 189 Made Her Cry Team Colleague

The typical way to do this is to create all the controls you need in the original document. You set the CSS Visibility property to "hidden" for the controls you don't want to show.

Then, code for some event (like a button click). The event handler would set the visibility property to "visible" for the controls you want to now show.

The other approach is to set the .innerText or .innerHTML property of a container element, such as a DIV.

If you search for ".innerHTML", you should find all the samples you need.

tgreer 189 Made Her Cry Team Colleague

What is a "layer"?

If you have a long page, with content divided up by use of anchor tags, you can navigate the page to a specific anchor with the URL syntax:

www.domain.com/page.html#anchorName

tgreer 189 Made Her Cry Team Colleague

Create an array. Store the ID of the DIVs into that array when the user makes them visible.

Each time they click a link to make a div visible, iterate through the array, toggling all the other divs.

tgreer 189 Made Her Cry Team Colleague

I would take a different approach. I would GENERATE the CSS from values stored in a database. Allow the users to modify these values, not by editing the CSS, which most users won't be skilled enough to do, but rather by presenting a standard data-entry form.

If you want to avoid server-side coding, then you could do something similar with cookies .

tgreer 189 Made Her Cry Team Colleague

HTML is a set of tags to describe a web page.

XML is a set of tags to describe any given type of hiercharchal data, depending on the schema for that data.

XHTML is an XML-compliant implementation of HTML.

So with XML, you could invent your own tags and properties to describe any package of data. You would create a schema that described your legal tags and properties. Then if enough people liked it, you could start exchanging XML data in your format, and possibly make it a standard.

That's what XHTML is - a standardized XML format/schema created for web pages.

All "ML" formats have SGML as the predecessor.

tgreer 189 Made Her Cry Team Colleague

What have you tried? Multiplying by "100" would appear to me to be the first step.

tgreer 189 Made Her Cry Team Colleague

I don't... that's what scrollbars are for!

I know you want an actual answer, not a lecture. Look at the "scrollTo" method, that should get you started.

However, consider that you are replicating a function that already exists and that users expect. When you take away something that a user expects, and replace it with something that isn't immediately obvious or more useful, you create a negative user experience.

tgreer 189 Made Her Cry Team Colleague

Exactly, the program is working and is fast. If the target byte (12) is within the last 14 elements of the char[] array, then I store everything after it into a "holding pen" char[]. set a switch, and let the loop fall through to get the next buffer. Then check the switch, finish out the "holding pen" array, and perform the test with it. All very neat and fast.

But the original question still remains. I'd like to examine the StreamReader object in more detail. Perhaps one could derive a class from it that exposed it's pointer to its internal buffer.

One could calculate the "virtual" position of the current character by taking the .Position of the underyling stream, subtracting the size of the buffer, and adding back in the value of the pointer.

tgreer 189 Made Her Cry Team Colleague

C# also provides a Seek() method. That does no good unless you know where to seek, which is what the posted code loop does.

Load the file as a string? A 2.3GB string? I don't think so!

The files in question are PCL files. Large "print" files. The files contain PCL Codes, as well as large amounts of raster data. The raster data may contain binary characters that could be of any value. So just searching for decimal "12" doesn't work. Each page ends with a FormFeed (decimal 12), and begins with a set of PCL codes. To determine if the "12" is a real FormFeed, I read the next few bytes to see if they are the "setup page" codes.

Why? Because the file has to be: split into "statements", which can have an arbitrary number of pages, barcodes must be added, sequence numbers, paper tray pull codes, etc.

The first step is to determine where, in the original file, each page begins and ends. That forms the basis for all other operations. Since those positions can be anywhere in the file, I have to read through the entire file to find them.

A buffered read, which is what StreamReader provides, is ideal. However, the StreamReader object provides no property or mechanism to relate it's position back to the actual position of the underlying stream.

None that I could find, anyway.

The larger "why" is, why not work with the original data, …

tgreer 189 Made Her Cry Team Colleague

...and the answer to this is that the curr_pos was calculated, and one of the terms in the calculation was an Int32, casting the entire result as an Int32.

Each term has to be cast to Int64 to maintain the integral type of the result.

tgreer 189 Made Her Cry Team Colleague

No one answered, and I found no answer on the web, either.

What I did was implement my own buffer. Instead of reading a byte at a time, I read in 8k at a time, using the FileStream. Then I did my search for the "12" in the bytes read, using a "for" loop.

It's a little tricky if the 12 is near the end of the buffer, since I need to check the next 14 bytes. So I use a working 14-byte array to store the last 14 bytes of the buffer each loop, and do some logic to handle that situation. It wasn't too tough.

What's frustrating is that this has to be done at all. The StreamReader obviously maintains an internal point to its own buffer. If that was exposed, then it would be easy to calculate the needed byte position.

tgreer 189 Made Her Cry Team Colleague

Let's see if I can completely strike-out, with a third unanswered post:

I would like to know how to store binary data in the app.config file for a C# application.

These are basically text strings, but they do include one or two "binary" characters, such as decimal 12.

I need these strings in my application, but would like to store them in the app.config file and get them with ConfigurationSettings.AppSettings.Get().

tgreer 189 Made Her Cry Team Colleague

Since nobody answered the thread on Binary File IO, I took a different approach.

Now I'm having another problem.

As I process a very large (>2GB) binary file, I store the byte position at certain points. Then, I reposition the file as needed.

I store the byte positions in a variable declared:

System.Int64 curr_pos;

However, the program fails when I position the file:

infile.Position = curr_pos;

I debug, and notice that this fails when the value of curr_pos gets over 2,147,483,647, which is the limit of a 32-bit integer. In fact, the value of curr_pos becomes negative, and that's the error I'm getting, that the value must be non-negative.

Why, since I explicitly declare the variable as 64-bit, does it fail when it reaches the 32-bit limit?

tgreer 189 Made Her Cry Team Colleague

Hi. I'm having some difficulty with a project that involves working with very large binary files. These are PCL files, where the decimal character "12" represents a Form Feed, but only if it's not embedded within a string of binary data.

In other words, I'm looking for decimal "12", then looking at the next few bytes to make sure it's really a form feed. I want to record the byte position of each "real" Form Feed, for futher processing down the line.

Here's what I have, it's working but extremely slow. The interesting part is in the "while" loop:

static void Main(string[] args)
{
	// need to initialize header and position of first page.
	filename = @"C:\Statements-05-03-05.pcl";
	infile = new FileStream(filename, FileMode.Open, FileAccess.Read);

	test = new byte[1024];
	infile.Read(test, 0 , test.Length);
	asciiChars = new char[ascii.GetCharCount(test, 0, test.Length)];
	ascii.GetChars(test, 0, test.Length, asciiChars, 0);
	asciiString = new string(asciiChars);

	header = asciiString.Substring(0,asciiString.IndexOf("*b0M") + 4);
	page_positions.Add(header.Length);

	counter = 1024;

	while (counter <= infile.Length )
	{   
		pcl_char = infile.ReadByte();
		counter++;
		if (pcl_char == 12)
		{
			test = new byte[14];
			curr_pos = infile.Position;

			infile.Read(test, 0, test.Length);
			counter = counter + 14;
			asciiChars = new char[ascii.GetCharCount(test, 0, test.Length)];
			ascii.GetChars(test, 0, test.Length, asciiChars, 0);
			asciiString = new string(asciiChars);

			if (asciiString == bgn_of_page)
			{
				page_positions.Add(curr_pos);

			} // if (new string(test) == bgn_of_page)
						
		} // if (pcl_char == 12)
	} // while (sr.Peek >= 0)
	infile.Close();
}

This is slow because I'm reading a single byte at a time. I check to see if the byte is …