tawboiid 0 Newbie Poster

Holy Smokes!

I found a solution. If I use the onclick event instead of onmousedown, it works perfectly. I don't know why there is a difference, or why the difference only affected my firefox.

I can't remember why I was using onmousedown in the first place, but there was a reason at one time. I'll have to go back and try onclick in the actual application and see if there are any other issues.

Thanks for the help along the way.

tawboiid 0 Newbie Poster

Hmmm...strange. I just upgraded to FF7 and for me, it still loses the cursor.

Just to reiterate, it only loses the cursor when you click on the text in the text box that gets cleared. If you click after the text, the cursor is retained.

Running FF7 on Windows XP box and a Windows Vista box.

tawboiid 0 Newbie Poster

Thanks for the reply. I am using Firefox 5. As a test, I loaded the test snippet into IE 8 and it worked fine from there (cursor was not lost).

So, this must be some kind of Mozilla glitch.

tawboiid 0 Newbie Poster

The problem is that I don't think the text box really loses focus. It just doesn't know where the cursor belongs. I have a onblur script and it doesn't activate in this situation. It only activates if you actually click somewhere else on the page.

It just seems to be that the text box doesn't know what to do with the cursor, so it doesn't do anything.

tawboiid 0 Newbie Poster

Oh, just in case you are going to reply to use:

document.getElementById(commentid).focus();

It doesn't work. Once the cursor is lost, setting the focus in this way does not reinstate the cursor.

tawboiid 0 Newbie Poster

I hope this hasn't been discussed before. I searched but couldn't find a thread for this.

I have an input (type="text") with some default text telling the user to enter something in the box. The input tag includes an onmousedown event which runs javascript function to clear the default text so the user can start entering their own text.

This setup behaves in two possible ways, one is good and one is bad:

Good: If the user clicks inside the text box, but after the default text, the text gets cleared and the cursor shows up at the beginning of the text box.

Bad: If the user clicks inside the text box, but directly on the default text, the text gets cleared, but the cursor is not displayed and the text box does not have the focus. In order to start typing, the user must click on the text box again.

So my question is: If the cursor is inside a string of text which gets cleared, is there a way to reinstate the cursor and the text box focus?

Here is simplified version of code involved:

<script type="text/javascript">
    function startcomment(commentid){
	document.getElementById(commentid).value = "";
    }
</script>

<input id="cid" type="text" value="Start a conversation about this" onmousedown="startcomment('cid')"></input>
tawboiid 0 Newbie Poster

I think I found what I was looking for (or at least something close). I found an article describing how to generate dynamic images on the fly using PHP.

http://www.webcheatsheet.com/PHP/dynamic_image_generation.php

Solved.

tawboiid 0 Newbie Poster

I was referring to the linked image that you can place on other web pages or blogs. It appears that Dani has a standard image background which dynamically gets changed with your username and member rank (or post count) etc..

So my question is how can you cause the link (example one below), to make the jpg image get overlayed with user related data and then displayed as one image?

<a href="http://www.daniweb.com/members/tawboiid/905390"><img
src="http://www.daniweb.com/certificates/member905390.jpg"
border="0" alt="tawboiid has contributed to DaniWeb"
width="120" height="90" /></a>

I was hoping the link above would show the image I am talking about, but it doesn't. You can see your own by going to your profile and looking in the bottom right corner. I am not talking about avatars.

tawboiid 0 Newbie Poster

This question is in regards to the little dynamic image that you can link to in your Daniweb profile (see profile page, bottom right).

I was curious how Daniweb is set up to dynamically create these images. I would like to do something similar on my site. Could Dani share some code here? Please?

tawboiid 0 Newbie Poster

The XP Machines are running .Net 4. Unfortunately I don't have access to a Win 7 machine at this time that has Visual Studio installed. So I can't recompile on a Win 7 machine. I may check with some of the other IT guys and see if I can find someone who does have the Win 7 setup with VS.

By the way, the App was compiled with VS2008 if that makes a difference.

tawboiid 0 Newbie Poster

Agree that some code is needed to even begin to help, however, as a starter make sure that your MySQL field where you want to store your image is setup as data type "Blob". Research MySQL help for the various blob sizes to set it for the appropriate images sizes you expect to store.

tawboiid 0 Newbie Poster

I have a C# App with a form which has a groupbox containing many controls. I have the groupbox anchored Top/Bottom/Left/Right to ensure that it sizes appropriately to the users screen resolution.

This app was developed on a machine running Windows XP and it has been working flawlessly for over a year on multiple XP boxes.

Now, our company is converting boxes to Windows 7. I've tested the app on 2 of the converted boxes and in both cases the groupbox refuses to auto anchor properly to the right and bottom. The form itself autosizes to full screen as you would expect, but the groupbox and all its contained controls does not.

Has anyone seen this sort of behavior when transitioning to Windows 7? Any solutions?

tawboiid 0 Newbie Poster

OK, I figured this out (and I'm a little embarrassed)....

The problem was that the field name "Counter" that I was using is a reserved word in Access. Once I changed the dB field name, my original code worked fine.

In my defense, the field name worked fine using similar code from VB6 code in classic ASP.

tawboiid 0 Newbie Poster

No good. The problem is not with the method of connecting or addressing the db connection, it is with the data type mismatch. As an example, if I take my original code and replace it with the following, it runs just fine with no problems (notice I commented out 3 lines and replaced them with three new lines which only processes string data:

OleDbConnection conn = null;
	conn = new OleDbConnection(sDbCounter);
	conn.Open();
	
	string strSQL = "SELECT * FROM Data WHERE AppName = 'F4WDAcronym'";

	OleDbDataAdapter objDataAdapter = new OleDbDataAdapter (strSQL, conn);
	OleDbCommandBuilder objCommandBuilder = new OleDbCommandBuilder (objDataAdapter);
	DataTable objDataTable = new DataTable();
	objDataAdapter.Fill(objDataTable);
	
		DataRow objDataRow = objDataTable.Rows[0];
		//string strCounter = objDataRow["Counter"].ToString();
		//int intCounter = Int32.Parse(strCounter) + 1;
		//objDataRow["Counter"] = intCounter;
	
		string strName = objDataRow["AppName"].ToString();
		strName = strName + "new";
		objDataRow["AppName"] = strName;
	
	objDataAdapter.Update(objDataTable);
	objDataAdapter.Dispose();	
	
	conn.Close();

This runs just fine and properly updates the Access database. The problem only shows up if I try to update an integer value. I've tried all the various integer types I could come up with but nothing works.

tawboiid 0 Newbie Poster

From the documentation "The DbCommandBuilder must execute the SelectCommand in order to return the metadata necessary to construct the INSERT, UPDATE, and DELETE SQL commands. As a result, an extra trip to the data source is necessary, and this can hinder performance. To achieve optimal performance, specify your commands explicitly rather than using the DbCommandBuilder."

I don't see where you are doing that.

Hmmmm...the code works perfectly if the only data being saved to the database is string data. I've used this same snippet in numerous other apps and ASP.Net web pages without problems, although in those cases the data was always string data.

I would be willing to try some other ADO methods if someone could give me some code snippets to try.

tawboiid 0 Newbie Poster

What is the type of objDataRow["Counter"] ?
C# is very strict on types.

In Access, the field is of data type "Number", and the Field Size property is set to "Long Integer". According to the Access documentation, this should be a 32 bit integer.

tawboiid 0 Newbie Poster

I am trying to read a long integer value from an Access database, do some math to the number, and save the result back to the database. I've never had a problem doing this with VB6, but with C# it is throwing an error when it tries to Update the data adapter. Error is: "Syntax Error in Update Statement".

string sPreConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
	string sPostConnString = ";Jet OLEDB:Database Password=xxxxxxx;";
	string sMdbPath = @"\\CMS\AppCounter.mdb"; 
	string sDbCounter = sPreConnString + sMdbPath + sPostConnString;

         OleDbConnection conn = null;
	conn = new OleDbConnection(sDbCounter);
	conn.Open();
	
	string strSQL = "SELECT * FROM Data WHERE AppName = 'F4WDAcronym'";

	OleDbDataAdapter objDataAdapter = new OleDbDataAdapter (strSQL, conn);
	OleDbCommandBuilder objCommandBuilder = new OleDbCommandBuilder (objDataAdapter);
	DataTable objDataTable = new DataTable();
	objDataAdapter.Fill(objDataTable);
	
		DataRow objDataRow = objDataTable.Rows[0];
		string strCounter = objDataRow["Counter"].ToString();
		int intCounter = Int32.Parse(strCounter) + 1;
		
		objDataRow["Counter"] = intCounter;
	
	objDataAdapter.Update(objDataTable);
	objDataAdapter.Dispose();	
	
	conn.Close();

I think the problem relates to a mismatch in datatypes when trying to save to Access. I've tried all the integer data types but can't seem to resolve this. If I comment out the "objDataRow["Counter"] = intCounter;" line then the code runs without errors.

Anyone have experience saving integer values to Access databases?