Showing posts with label wrong. Show all posts
Showing posts with label wrong. Show all posts

Wednesday, March 28, 2012

Strange Characters

Hello,

I have a form with a textbox.

When I click submit the text in the textbox changes.

For example "Andr Sousa" becomes "André Sousa"

What is wrong and how can I solve this?

Thanks,

Miguel"shapper" <mdmoura@.gmail.comwrote in message
news:1169488427.871757.44860@.s34g2000cwa.googlegro ups.com...

For example "Andr Sousa" becomes "André Sousa"

Whenever one "unusual" character gets substitued by two even more "unusual"
characters, you can be pretty certain it's a Unicode encoding issue...

Post your code...

Strange characters

Hello,

I have a form with a textbox.

When I click submit the text in the textbox changes.

For example "André Sousa" becomes "Andr?? Sousa"

What is wrong and how can I solve this?

Thanks,

Miguel

try use

Server.HtmlDecode
Server.HtmlEncode

see how it goes


Hi,

Can you show me your code, I am glad to check it in my computer for you.

Monday, March 26, 2012

Strange Error !

Strange Error !!!

Help please.. i was testing my application today and i get this error message for the first time
and i don't know what i did wrong.. or what causing it.. i didn't get this error before
only today..the error is :

Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

please help me..it is driving me crazy.. because i tried to track it down using breakpoints but it didn't work

Regards,

Nina

Hey you might have build your application, but still the browser is getting reference from the previous builds. Just try a refresh of your page or a new browser window

HTH


i did what you asked me and still getting the error

Saturday, March 24, 2012

strange error in a very simple method - what is wrong with asp.net?

Hello,

I have a simple method, which looks from my point of view entirely correct, but I
get the error:

;expected (in the line of declaration, CreateDataTable is red underlined )

The code is the following:

private void DataTable CreateDataTable(string selection){
int maxrowindex;

switch (selection)
{
case "newtable" :

DataColumn myDataColumn;
DataRow myDataRow;
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.Int32");
myDataColumn.ColumnName = "id";
myDataColumn.ReadOnly = false;
myDataColumn.Unique = true;
myDataTable.Columns.Add(myDataColumn);

myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "Material";
myDataColumn.AutoIncrement = false;
myDataColumn.Caption = "Material";
myDataColumn.ReadOnly = false;
myDataColumn.Unique = false;
myDataTable.Columns.Add(myDataColumn);

myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.Int32");
myDataColumn.ColumnName = "Amount";
myDataColumn.AutoIncrement = false;
myDataColumn.Caption = "Amount";
myDataColumn.ReadOnly = false;
myDataColumn.Unique = false;
myDataTable.Columns.Add(myDataColumn);

DataColumn[] PrimaryKeyColumns = new DataColumn[1];
PrimaryKeyColumns[0] = myDataTable.Columns["id"];
myDataTable.PrimaryKey = PrimaryKeyColumns;

//myDataSet = new DataSet();
//myDataSet.Tables.Add(myDataTable);

myDataRow = myDataTable.NewRow();
myDataRow["id"] = 1;
myDataRow["Material"] = "Bezeichnung ";
myDataRow["Amount"] = 0;
myDataTable.Rows.Add(myDataRow);
maxrowindex = 1;

break;

case "newrow" :

break;

case "deleterow" :
break;
}

}


Does anybody know what is wrong?void or DataTable, pick one.
thanks!

Thursday, March 22, 2012

Strange issue with Environment.NewLine in SQL

First off, apologies if this is in the wrong board.

I'm going to ramble a bit here in an attempt to get my thoughts together...

Background:

So I have this message board I've built using ASP.Net 2.0 and SQL 2005. I'd link you to it, but the particular site in question is a bit of a free for all so I can't guarantee you won't find something offensive =P.

Anyways, the important thing to note is that posts are typed into a multiline textbox, and saved 'as is' in the relevant SQL table as varchar. When a topic is displayed, this text is converted into HTML: Environment.NewLine -> <br />, weird messageboard tags into HTML (bold, italic, etc.), and so on.

Now this is all fine and dandy but lately a weird issue has came up.

Issue:

The odd time, when a particular person makes a post, his NewLine characters get lost somewhere. What I mean is he'll type something with pretty paragraph breaks and nice formatting and then it'll be displayed as a solid block of text.

But here's where things get funky - if I click to edit his post (at which point the text is displayed 'as is' from the SQL table into another textbox), it displays as it should, with the line breaks. If I save the changes without altering the text at all, his post will now display properly. I can also quote his single-block-of-text post and it will display as multiple paragraphs within my own post.

All I can figure is that maybe something strange is happening for different users as they saved their posts.

Some things to note:

I looked through the SQL tables at three identical posts, one posted by user A, who had his post turn into a single block of text, one by me, whose post displayed properly, and another consisting of user A's post copy/pasted by me (just to ensure I didn't miss anything when retyping his post). Again, this last post displayed properly.

The hexadecimal code for the line-breaks in my post was 0x0D 0x0A, which corresponds to the CRLF code for Windows. Makes sense since I'm using Windows. This was again the case for my second post, the copy/pasted version of User A's original post. Though when I look at his post, the line-break characters come up as 0x0A, which is the LF code for users running a Mac. This makes less sense because I know the guy is running Windows.

But maybe I'm overthinking this and I should be using a unicode variable type in the SQL? Any suggestions would be welcome.

Cheers

apedrape83:

The hexadecimal code for the line-breaks in my post was 0x0D 0x0A, which corresponds to the CRLF code for Windows. Makes sense since I'm using Windows. This was again the case for my second post, the copy/pasted version of User A's original post. Though when I look at his post, the line-break characters come up as 0x0A, which is the LF code for users running a Mac. This makes less sense because I know the guy is running Windows.

You know he is using Windows because you have observed this with your own eyes? Or because he told you? Maybe he's running windows on a Mac, and this is a "feature".


Oh snap, just found this:http://forums.asp.net/p/1186555/2027418.aspx

He's running windows (he sent me screenshots while I was requesting his assistance in debugging), so yeah, saw it with my own eyes more or less. BUT, he's also running FireFox and doesn't have a problem in IE7. I overlooked this because it worked fine on my own FireFox, which is a different version than his.

I'm going to have to read more into this issue with FireFox and see if the way it chooses to save NewLines explains the truncated hex values I described.


Anyways, the problem was solved by grabbing all of the '\r\n' breaks out of the string as put in by IE7 and replacing them with the html followed by grabbing the leftover '\n' breaks used by other browsers as the NewLine in a textbox and replacing those as opposed to replacing the Environment.NewLine directly.