Showing posts with label inserted. Show all posts
Showing posts with label inserted. Show all posts

Wednesday, March 28, 2012

Strange character transformations

Hi,

I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.

This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char ? (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)

Has anyone seen this behaviour before, and know how to stop it?
The code's simple - here's an example. The ? appears in the output
where the input is +Anu - it's transformed before I can touch it!

using (StreamReader sr = new StreamReader(strFile,
System.Text.Encoding.UTF7)) {
// Read and display lines from the file until the end of the file is
reached.
while ((line = sr.ReadLine()) != null) {
Response.Write(line);
}
}

Regards

AdamLooks like an encoding issue, alright.
Have you tried using the StreamReader constructor that does not require a
character encoding?

"CyberSpyders@.gmail.com" wrote:

Quote:

Originally Posted by

Hi,
>
I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.
>
This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char ? (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)
>
Has anyone seen this behaviour before, and know how to stop it?
The code's simple - here's an example. The ? appears in the output
where the input is +Anu - it's transformed before I can touch it!
>
using (StreamReader sr = new StreamReader(strFile,
System.Text.Encoding.UTF7)) {
// Read and display lines from the file until the end of the file is
reached.
while ((line = sr.ReadLine()) != null) {
Response.Write(line);
}
}
>
Regards
>
Adam
>
>


Graven,

I'm not sure how a 4 letter string like this could be seen as an
encoding issue, but I will certainly give it a go. Thanks for the
suggestion.

Adam

Graven wrote:

Quote:

Originally Posted by

Try to use plain latin-1 encoding. I think it's an unicode
normalization issue, but don't know if StreamReader performs it by
default.
>
>
CyberSpyders@.gmail.com wrote:

Quote:

Originally Posted by

Hi,

I have an ASP.Net website, which allows users to upload a file which is
then inserted into a database.

This is all fine until it reads a line with the string +Anu in it.
It transforms this to this char ? (which, if Googled for, is
described as Unicode Character 'LATIN SMALL LETTER TURNED R WITH HOOK'
(U+027B) or, in Phonetics, as a 'Retroflex approximant'.)

Has anyone seen this behaviour before, and know how to stop it?
The code's simple - here's an example. The ? appears in the output
where the input is +Anu - it's transformed before I can touch it!

using (StreamReader sr = new StreamReader(strFile,
System.Text.Encoding.UTF7)) {
// Read and display lines from the file until the end of the file is
reached.
while ((line = sr.ReadLine()) != null) {
Response.Write(line);
}
}

Regards

Adam


Larry,

You were spot on - changing to UTF8 stopped this transformation. Thanks

It's not quite solved my problem though.
The file is a Text file, each line being a series of files delimited by
the character, as this was unliekley to ever appear in the actual
data.

Unfortunately, UTF8 encoding strips these characters completely. ASCII
encoding, on the other hand, replaces them with ?

Oh the joy of character encoding.

Regards

Adam

Larry Lard wrote:

Quote:

Originally Posted by

This is why you are seeing what you are seeing. UTF7 encodes characters
outside the printable 7 bit range using UTF16 then modified base64, with
+ as the indicator mark for this encoding. I haven't checked, but I
imagine +Anu is the UTF7 encoding of that character. You shouldn't use a
UTF7 reader to read a file that you don't know for sure was produced by
a UTF7 writer.
>
The correct way to read the file depends on what kind of file it is. If
it is text of an unknown encoding, there is no way to be absolutely
sure, but UTF8 is a good starting point. If it's binary data, you
shouldn't be using a TextReader class at all.

Thursday, March 22, 2012

strange hyperlink focus problem

i have inserted a hyperlink into a form:

<asp:hyperlink id="OpenCalendarLink" runat="server" imageurl="../../images/button_calendar.gif">
</asp:hyperlink>

there is an <asp:textbox> before my hyperlink but when I tab out of my textbox the cursor focus jumps past my hyperlink. I have tried tabbing all across the page and the cursor never focuses on my hyperlink. Yet on a different page I have a hyperlink within the <edititemtemplate> of a dataSet and the cursor focuses on the hyperlink within that page.

can anyone help me solve this problem please!Post the code to the ASPX page and I'll take a look.
here is my code thanks darrell:


<%@. Page language="c#" Debug="true" Codebehind="trnew.aspx.cs" AutoEventWireup="false" Inherits="PinpointOnline.TimeRecordingNewPage" %>
<%@. Register TagPrefix="date" Namespace="PeterBlum.PetersDatePackage" Assembly="PetersDatePackage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
<html>
<head>
<title>PINPOINT ONLINE</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="http://links.10026.com/?link=../../css/timerecording.css" type="text/css">
<script language="JavaScript">
function SelectMatter(){
var lookupWin = window.open('../misc/mattersearch.aspx?parent=trnew&by=Code&page=1&totpages=0&for='
+ window.document.forms['TRNewForm'].elements['NewDisplayCodeTB'].value,
'mattersearchWin', 'scrollbars=yes,resizable=yes,width=660,height=500', true);
}
function SelectAttCode(){
var lookupWin = window.open('../misc/attcodesearch.aspx?fecode=0&rscode=2&dcode=SPE0287&by=Code&page=1&totpages=0&for='
+ window.document.forms['TRNewForm'].elements['NewAttCodeTB'].value,
'attcodesearchWin', 'scrollbars=yes,resizable=yes,width=660,height=500', true);
}
function submitit()
{
document.forms[0].action="trview.aspx";
document.forms[0].target="viewFrame";
document.forms[0].__VIEWSTATE.name = 'NOVIEWSTATE';
document.forms[0].submit();
self.TRNewForm.NewDateTB.focus();
}
</script>
</head
<body class=bodystyle2 text=#000000
onload=javascript:self.TRNewForm.NewDateTB.focus();>
<form id=TRNewForm runat="server">
<div id=Layer1
style="Z-INDEX: 1; LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 10px">
<table class=tablenew1 cellspacing=0 cellpadding=0 width="100%" border=0>
<tbody>
<tr>
<td nowrap=true>
Date:
<date:datetextbox class=formcontent3 id=NewDateTB
runat="server" xinitiallyblankrule="Today"
xinvaliddatemsg=" " xerrorbackcolor="Red"
columns="11" xshowpopupb="False"
xenablecontextmenub="False">
</date:datetextbox>
<asp:hyperlink id=LoadCalendarPopupLink
onclick="javascript:calendar_window=window.open('../misc/calendar.aspx?form=TRNewForm&textbox=NewDateTB','DatePicker','width=220,height=179,left=134,top=80'); calendar_window.focus();"
runat="server"
imageurl="../../images/button_calendar.gif">
</asp:hyperlink>
</td>
<td align=right width="100%">
<date:datetextboxvalidator id=NewDateTBValidator runat="server"
controltovalidate="NewDateTB"
font-bold="True">
</date:datetextboxvalidator>
<input class=formcontent1 readonly=true size=12
name=NewTimeDisplayTB><input class=formcontent1 onclick=stopWatch1.startclock() tabindex=-1
type=button value=start name=NewStartClockButton><input class=formcontent1 onclick=stopWatch1.stopclock() tabindex=-1
type=button value=stop name=NewStopClockButton><input class=formcontent1 onclick=stopWatch1.resetclock() tabindex=-1
type=button value=reset name=NewResetClockButton>
</td>
</tr>
</tbody>
</table>
<table class=tablenew2 cellspacing=0 cellpadding=0 width="100%" border=0>
<tbody>
<tr>
<td nowrap=true>
Matter:
<asp:textbox class=formcontent4 id=NewDisplayCodeTB tabindex=-1
runat="server" readonly="true" size="12"
maxlength="12">
</asp:textbox>
<input class=formcontent1 onclick=SelectMatter(); type=button
value=... name=LoadMatterSearchPopUpButton>
</td>
<td nowrap=true>
Client:<input class=formcontent1 tabindex=-1 readonly=true maxlength=50 size=50
name=NewDisplayNameTB>
</td>
<td valign=baseline nowrap=true width="100%">
LA:<img height=13 src="http://pics.10026.com/?src=../../images/checkbox_blank.gif" width=13 align=absMiddle
name=NewLAImage>
</td>
</tr>
</tbody>
</table>
<table class=tablenew3 cellspacing=0 cellpadding=0 width="100%" border=0>
<tbody>
<tr>
<td nowrap=true>
Narrative:
<asp:textbox class=formcontent1 id=NewNarrativeTB
runat="server" size="50" maxlength="50">
</asp:textbox>
</td>
<td nowrap=true>
Rate:
<asp:dropdownlist id=NewRateSchemeDDL runat="server"
enabled="false" cssclass="formcontent1">
</asp:dropdownlist>
</td>
<td nowrap=true>
AT:
<asp:textbox class=formcontent1 id=NewAttCodeTB runat="server"
size="7" maxlength="7">
</asp:textbox>
<input class=formcontent1 onclick=SelectAttCode(); type=button
value=... name=LoadAttCodeSearchPopupButton>
</td>
<td nowrap=true>
Time/Units:
<asp:textbox class=formcontent1 id=NewUnitsTB runat="server"
size="6" maxlength="6">
</asp:textbox>
</td>
<td nowrap=true width="100%">
<asp:button id=SubmitFormButton runat="server"
cssclass="formcontent2" value="submit" text="Submit">
</asp:button>
</td>
</tr>
</tbody>
</table>
<table class=tablenew4 cellspacing=0 cellpadding=0 width="100%" border=0>
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
</div>
</form>
</form>
</tr>
</tbody>
</table>
<div>
</div>
</form>
</body>
</html>

Strange Image Problem

I have created a master page and inserted a couple images. When I look at them in design view the appear as a box with an x in it which is not correct. When I view the page in the browser it displays the image. What is the problem?

Here is the master page code:

<%@dotnet.itags.org. Master Language="VB" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
<img src="http://pics.10026.com/?src=Images/delilogo.jpg" runat="server"/><br /> <img src="http://pics.10026.com/?src=Images/topmenu.jpg" runat="server"/>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder></center>
</div>
</form>
</body>
</html>

The designer in VS is no good. I would rely on your source and forget the designer most of the time. But if you really want the images to appear in the designer, try draging and dropping your images from VS Solution Explorer onto the designer surface.

Hope this helps.


Hinzamorski ,

try the following:

<asp:ImageID="Image1"runat="server"ImageUrl="~/im.JPG"/>


Hi nzamorski,

I'm sure this should work as well as the asp:Image control.

<img src="http://pics.10026.com/?src=Images/delilogo.jpg" runat="server"/>

First, where is your website project located? Is it IIS project or File System project? Please double check the folder structure if the relative path to Images/delilogo.jpg is right. When the website is located in IIS server, the relatvie path to the image in a virtual directory or a web application might be different.

I agree with the guys above, you can drag and drop the image if you are not certain of the path to the image. But first make sure the Images folder is in the root folder of the project. Thus you will find the folder is appearing in the Solution Explorer window of Visual Studio. Pick up the image and drag & drop it into the Design View will be simpler.

Hope it helps.