Showing posts with label text. Show all posts
Showing posts with label text. Show all posts

Saturday, March 31, 2012

Story Ads

Hi,

We have all seen them. Those square ads inside of textual content wherethe text wraps around the ad. The ad is about halfway down the text andit floats either left, or right.

What would be the best way to do those kinds of ads? I imagine youcould take the text and count to...let's say 300 characters from theleft, insert the ad and then pick up the text starting at position 301.This seems crude and might cause problems. If the text includes htmltags, position 300 may be an opening, or closing caret, which wouldmess with the formatting.

Any ideas on how to do this in a more elegant way?

Thanks!

<img align=right src="http://pics.10026.com/?src=somepage.aspx">

This will wrap text around it, aligning it on the right and let you use "somepage.aspx" to generate the ad

Strange behavior by the codebehind

Hello, all. I created a few Label objects, and deleted some. However, later
when I was using the codebehind page in VS .NET 2003 to set the Text of the
existing labels, I noticed that when I hit the period at the end of this"
"Me." I got the labels that had been deleted from the form's HTML. I
accidentally selected an item that was no longer on the form, and it took me
a few hours to debug that error "Object reference not set to an instance of
an object." I ultimately had to shut VS .Net down and restart it before I
even saw the new labels I had added. Hitting Refresh at the top of the
Solution Explorer didn't help.
Is this a known issue? Why am I still seeing the deleted Label objects when
I hit "Me."? Anyway to clear those items out permanently? I usually test my
pages without doing Rebuild, but by hitting F5. Could that have something to
do with it? Thanks.I think I've seen what you are talking about. Any time I add control in
HTML, I ALWAYS swith to the Design tab. This seems to synchronize the
codebehind (it doesn't always remove old controls though). Of course, some
people avoid the Design tab like the plague, in which case you need to add
your code-behind declarations manually.
In your codebehind, if you expand the #Region " Web Form Designer Generated
Code " section. You'll see all the current (and probably past) control
declarations you had on your form. It is safe to delete any orphaned ones.
Greg
"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> Hello, all. I created a few Label objects, and deleted some. However,
> later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
> the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it took
> me
> a few hours to debug that error "Object reference not set to an instance
> of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
> when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
> my
> pages without doing Rebuild, but by hitting F5. Could that have something
> to
> do with it? Thanks.
>
I wouldn't call it a bug, just a limitation of what VS.Net can safely do.
In your codebehind, you'll notice a region named #Region " Web Form Designer
Generated Code ", if you expand this, you'll see all those labels you
deleted in the aspx file still declared. That's what Me. uses to show that
list...you can safely delete them.
When VS.Net adds those controls to that region, it does so 'cuz it found
them on your page, but when you remove them, vs.net can't safely remove
them..just because it isn't on the page doesn't mean you aren't dynamically
creating them in codebehind.
The new code-besides model of ASP.Net 2.0 makes these declaration dissapear,
along with the problem.
Karl
MY ASP.Net tutorials
http://www.openmymind.net/
"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> Hello, all. I created a few Label objects, and deleted some. However,
later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it took
me
> a few hours to debug that error "Object reference not set to an instance
of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
my
> pages without doing Rebuild, but by hitting F5. Could that have something
to
> do with it? Thanks.
>
On Mon, 6 Sep 2004 12:23:20 -0400, dw <cougarmana_NOSPAM@.uncw.edu> wrote:

> Hello, all. I created a few Label objects, and deleted some. However,
> later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
> the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it
> took me
> a few hours to debug that error "Object reference not set to an instance
> of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
> when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
> my
> pages without doing Rebuild, but by hitting F5. Could that have
> something to
> do with it? Thanks.
>
VS.NET does not delete those old references very well (the variable
declarations at the top of the code-behind class, sometimes they're hidden
in the auto-generated section, that's why you see them). I know for a
fact if you're going to rename a control on the aspx, do it in the Design
View, in the Properties window for that control. Otherwise the name does
not get updated on the codebehind (especially if you do it in the HTML
view).
As far as deleting, I'm not sure, but it's pry just as quirky. Try
deleting it on the Design view, not in the HTML view of the aspx. Then I
usually always switch to Design view after updating my .aspx and
double-click on the document to have VS.NET switch over to the code-behind
automatically. Seems it's then able to do things a little more cleanly,
though things you delete may still not get cleaned up as well.
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> I got the labels that had been deleted from the form's HTML.
1. Make sure that you always mess around with the IDE tab, not the HTML tab.
2. Also, leave the auto generated code Region alone, do not add/modify this
region because IDE thinks that it no longer owns it and will not clean it
properly for you. I tried to trick it by adding couple of blanks and I can
repeat the problem.
3. Keep in mind that it will never get grid of "user's event/behavior" for
you, which is good, you will have to clean it yourself if you decide not to
keep the code.
John
Thank you, Greg, Craig, Karl, and WJ. All make perfect sense. Yes, I was
editing the code in HTML, and so VS couldn't know of the items I'd added or
deleted. For awhile there, I thought I'd broken VS. Thanks for your help :)
"WJ" <JohnWebbs@.HotMail.Com> wrote in message
news:uXLn7NDlEHA.3496@.TK2MSFTNGP12.phx.gbl...
> "dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
> news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> 1. Make sure that you always mess around with the IDE tab, not the HTML
tab.
> 2. Also, leave the auto generated code Region alone, do not add/modify
this
> region because IDE thinks that it no longer owns it and will not clean it
> properly for you. I tried to trick it by adding couple of blanks and I can
> repeat the problem.
> 3. Keep in mind that it will never get grid of "user's event/behavior" for
> you, which is good, you will have to clean it yourself if you decide not
to
> keep the code.
> John
>
On Mon, 6 Sep 2004 12:43:31 -0400, Karl <karl REMOVE @. REMOVE openmymind
REMOVEMETOO . ANDME net> wrote:

> When VS.Net adds those controls to that region, it does so 'cuz it found
> them on your page, but when you remove them, vs.net can't safely remove
> them..just because it isn't on the page doesn't mean you aren't
> dynamically
> creating them in codebehind.
>
I always wondered if that was what they were really doing, but I still
considered it annoying...
Unfortunately being an OO purist, I'm not too high on the partial type
approach of 2.0 either, oh well :) I still have my business layer...
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Particularly annoying is that I cannot set the base class for my page
in code, I have to modify the Inherits attribute VS.NET sticks in the
@. Page directive...
Scott
http://www.OdeToCode.com
On Mon, 06 Sep 2004 12:18:21 -0500, "Craig Deelsnyder"
<cdeelsny@.no_spam_4_meyahoo.com> wrote:

>On Mon, 6 Sep 2004 12:43:31 -0400, Karl <karl REMOVE @. REMOVE openmymind
>REMOVEMETOO . ANDME net> wrote:
>
>I always wondered if that was what they were really doing, but I still
>considered it annoying...
>Unfortunately being an OO purist, I'm not too high on the partial type
>approach of 2.0 either, oh well :) I still have my business layer...

Strange behavior by the codebehind

Hello, all. I created a few Label objects, and deleted some. However, later
when I was using the codebehind page in VS .NET 2003 to set the Text of the
existing labels, I noticed that when I hit the period at the end of this"
"Me." I got the labels that had been deleted from the form's HTML. I
accidentally selected an item that was no longer on the form, and it took me
a few hours to debug that error "Object reference not set to an instance of
an object." I ultimately had to shut VS .Net down and restart it before I
even saw the new labels I had added. Hitting Refresh at the top of the
Solution Explorer didn't help.

Is this a known issue? Why am I still seeing the deleted Label objects when
I hit "Me."? Anyway to clear those items out permanently? I usually test my
pages without doing Rebuild, but by hitting F5. Could that have something to
do with it? Thanks.I think I've seen what you are talking about. Any time I add control in
HTML, I ALWAYS swith to the Design tab. This seems to synchronize the
codebehind (it doesn't always remove old controls though). Of course, some
people avoid the Design tab like the plague, in which case you need to add
your code-behind declarations manually.

In your codebehind, if you expand the #Region " Web Form Designer Generated
Code " section. You'll see all the current (and probably past) control
declarations you had on your form. It is safe to delete any orphaned ones.
Greg

"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> Hello, all. I created a few Label objects, and deleted some. However,
> later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
> the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it took
> me
> a few hours to debug that error "Object reference not set to an instance
> of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
> when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
> my
> pages without doing Rebuild, but by hitting F5. Could that have something
> to
> do with it? Thanks.
I wouldn't call it a bug, just a limitation of what VS.Net can safely do.
In your codebehind, you'll notice a region named #Region " Web Form Designer
Generated Code ", if you expand this, you'll see all those labels you
deleted in the aspx file still declared. That's what Me. uses to show that
list...you can safely delete them.

When VS.Net adds those controls to that region, it does so 'cuz it found
them on your page, but when you remove them, vs.net can't safely remove
them..just because it isn't on the page doesn't mean you aren't dynamically
creating them in codebehind.

The new code-besides model of ASP.Net 2.0 makes these declaration dissapear,
along with the problem.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/

"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> Hello, all. I created a few Label objects, and deleted some. However,
later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it took
me
> a few hours to debug that error "Object reference not set to an instance
of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
my
> pages without doing Rebuild, but by hitting F5. Could that have something
to
> do with it? Thanks.
On Mon, 6 Sep 2004 12:23:20 -0400, dw <cougarmana_NOSPAM@.uncw.edu> wrote:

> Hello, all. I created a few Label objects, and deleted some. However,
> later
> when I was using the codebehind page in VS .NET 2003 to set the Text of
> the
> existing labels, I noticed that when I hit the period at the end of this"
> "Me." I got the labels that had been deleted from the form's HTML. I
> accidentally selected an item that was no longer on the form, and it
> took me
> a few hours to debug that error "Object reference not set to an instance
> of
> an object." I ultimately had to shut VS .Net down and restart it before I
> even saw the new labels I had added. Hitting Refresh at the top of the
> Solution Explorer didn't help.
> Is this a known issue? Why am I still seeing the deleted Label objects
> when
> I hit "Me."? Anyway to clear those items out permanently? I usually test
> my
> pages without doing Rebuild, but by hitting F5. Could that have
> something to
> do with it? Thanks.

VS.NET does not delete those old references very well (the variable
declarations at the top of the code-behind class, sometimes they're hidden
in the auto-generated section, that's why you see them). I know for a
fact if you're going to rename a control on the aspx, do it in the Design
View, in the Properties window for that control. Otherwise the name does
not get updated on the codebehind (especially if you do it in the HTML
view).

As far as deleting, I'm not sure, but it's pry just as quirky. Try
deleting it on the Design view, not in the HTML view of the aspx. Then I
usually always switch to Design view after updating my .aspx and
double-click on the document to have VS.NET switch over to the code-behind
automatically. Seems it's then able to do things a little more cleanly,
though things you delete may still not get cleaned up as well.

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
"dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> I got the labels that had been deleted from the form's HTML.

1. Make sure that you always mess around with the IDE tab, not the HTML tab.

2. Also, leave the auto generated code Region alone, do not add/modify this
region because IDE thinks that it no longer owns it and will not clean it
properly for you. I tried to trick it by adding couple of blanks and I can
repeat the problem.

3. Keep in mind that it will never get grid of "user's event/behavior" for
you, which is good, you will have to clean it yourself if you decide not to
keep the code.

John
Thank you, Greg, Craig, Karl, and WJ. All make perfect sense. Yes, I was
editing the code in HTML, and so VS couldn't know of the items I'd added or
deleted. For awhile there, I thought I'd broken VS. Thanks for your help :)

"WJ" <JohnWebbs@.HotMail.Com> wrote in message
news:uXLn7NDlEHA.3496@.TK2MSFTNGP12.phx.gbl...
> "dw" <cougarmana_NOSPAM@.uncw.edu> wrote in message
> news:%23ajHX3ClEHA.3340@.TK2MSFTNGP14.phx.gbl...
> > I got the labels that had been deleted from the form's HTML.
> 1. Make sure that you always mess around with the IDE tab, not the HTML
tab.
> 2. Also, leave the auto generated code Region alone, do not add/modify
this
> region because IDE thinks that it no longer owns it and will not clean it
> properly for you. I tried to trick it by adding couple of blanks and I can
> repeat the problem.
> 3. Keep in mind that it will never get grid of "user's event/behavior" for
> you, which is good, you will have to clean it yourself if you decide not
to
> keep the code.
> John
On Mon, 6 Sep 2004 12:43:31 -0400, Karl <karl REMOVE @. REMOVE openmymind
REMOVEMETOO . ANDME net> wrote:

> When VS.Net adds those controls to that region, it does so 'cuz it found
> them on your page, but when you remove them, vs.net can't safely remove
> them..just because it isn't on the page doesn't mean you aren't
> dynamically
> creating them in codebehind.
I always wondered if that was what they were really doing, but I still
considered it annoying...

Unfortunately being an OO purist, I'm not too high on the partial type
approach of 2.0 either, oh well :) I still have my business layer...

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Particularly annoying is that I cannot set the base class for my page
in code, I have to modify the Inherits attribute VS.NET sticks in the
@. Page directive...

--
Scott
http://www.OdeToCode.com

On Mon, 06 Sep 2004 12:18:21 -0500, "Craig Deelsnyder"
<cdeelsny@.no_spam_4_meyahoo.com> wrote:

>On Mon, 6 Sep 2004 12:43:31 -0400, Karl <karl REMOVE @. REMOVE openmymind
>REMOVEMETOO . ANDME net> wrote:
>>
>> When VS.Net adds those controls to that region, it does so 'cuz it found
>> them on your page, but when you remove them, vs.net can't safely remove
>> them..just because it isn't on the page doesn't mean you aren't
>> dynamically
>> creating them in codebehind.
>>
>I always wondered if that was what they were really doing, but I still
>considered it annoying...
>Unfortunately being an OO purist, I'm not too high on the partial type
>approach of 2.0 either, oh well :) I still have my business layer...

Wednesday, March 28, 2012

Strange bug with textbox.text property

I have this is my page_load

txtSearchTerm.text = "All"

Then I have an imagebutton, when its clicked I want to redirect to a page based on the value of that textbox.

So in my imagebutton click event I have

Response.Redirect("auctions.aspx?search=" + txtSearchTerm.text)

My problem is this text is always "All", even when the user changes the value of the textbox

????

Help !

put you initialize in !IsPostBack

if(!IsPostBack){this.txtSearchTerm.Text="ALL";}

or you can set the default value in the form .aspx file use Text="ALL"


hi,

zeroxp kind of touch it a little, but i want to add something to his reply.

whenever a client click on a button on your webform, asp.net actually will reload itself, then process the Button1_Click event. Therefore, if you want to do something when the page is load, but not everytime it refrashes, use if (!IsPostBack){} or in vb.net: if page.ispostback = false then .

Just want to remind all people out there who maybe thinking this is a bug.. no it isn't... just the way asp.net webform was designed.

Alan,

Strange character [Â] appearing in file.

Hi All,

I have an ASP.NET application which opens a text file and then saves it again.
This saved file is then passed into another software suite (not ASP.NET) for processing.
This secondary suite expects the lines in the file to be a certain length (legacy).

All text is transferred between the files correctly, except for where a uk pound sign [£] appears in the original file.

This character is NOT transferredusing the default StreamReader/Writer.

I havetriedchanging the encoding of both the StreamReader and the StreamWriter butcannot find one which does the job as expected, changing the reader toASCII and leaving the default writer is the closest but not withoutissues.
Where thiscondition occurs, the resulting saved file, in the place where theoriginal pound sign was displayed shows 2 (!) characters ?£.

This extra ? [alt + 0194] character is not seen by Notepad, not visiblewhen debugging, but is there, as it affects the fixed length recordprocessing mentioned above, and can be seen in other text editors suchas Wordpad, DocPad etc.

Please help, this is causing some despair!

Thanks and Regards,
Ric

The following code sample demonstrates my point...
[A file c:\testInput.txt is also required with a line in it that contains a £ sign]
eg. 111111111111111£1111111111
[A file c:\testOutput.txt is created to demonstrate the point.]

Sub Main()

'file access vars
Dim fsRead As FileStream
Dim fsWrite As FileStream
Dim sr As StreamReader
Dim sw As StreamWriter

'The file to read from
Dim inputFile As String = "c:\testInput.txt"
Dim outputFile As String = "c:\testOutput.txt"

'Create the FileStream : INPUT
Try
fsRead = New FileStream(inputFile, FileMode.Open, FileAccess.Read,FileShare.Read)
Catch ex As Exception
End Try

'Create the StreamReader
Try
sr = New StreamReader(fsRead, System.Text.Encoding.ASCII)
Catch ex As Exception
End Try

'Create the FileStream : OUTPUT
Try
fsWrite = New FileStream(outputFile, FileMode.OpenOrCreate,FileAccess.Write, FileShare.ReadWrite)
Catch ex As Exception
End Try

'Create the StreamWriter
Try
sw = New StreamWriter(fsWrite)
Catch ex As Exception
End Try

Dim s As String
Dim replaced As String
While sr.Peek <> -1

'read a line form the input file
s = sr.ReadLine()

'substitute the misread ? characters into £ signs
replaced = Replace(s, "?", "£")

'move to the end of the file
sw.BaseStream.Seek(0, SeekOrigin.End)

'and write the string to the output file
sw.Write(replaced & vbCrLf)

End While

'Clear up...
Try
sw.Flush()
sw.Close()
fsWrite.Close()

sr.Close()
fsRead.Close()

Catch ex As Exception
End Try

'and dispose
sw = Nothing
sr = Nothing
fsRead = Nothing
fsWrite = Nothing

End Sub

Solution:

When reading/writing plain text files using file streams on a Windows box you should specify an Encoding.

The Encoding can be created using the following code:
[1252 is the Western Windows codepage]

Dim encAs System.Text.Encoding
enc = System.Text.Encoding.GetEncoding(1252)

You can then specify this encoding to be used when creating the StreamReader/StreamWriter.

All characters (even the uk pound sign £) will then be correctly read/written by the streams.

Hope this helps,
Ric

Strange Characters

Hello,
I have a form with a textbox.
When I click submit the text in the textbox changes.
For example "Andr=E9 Sousa" becomes "Andr=C3=A9 Sousa"
What is wrong and how can I solve this?
Thanks,
Miguel"shapper" <mdmoura@.gmail.com> wrote in message
news:1169488427.871757.44860@.s34g2000cwa.googlegroups.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"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.

Strange Characters in Asp.Net Text Box

Hello,

I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as "??áàéí" when I load the data again I get a few strange characters: "?§?£??? ???"

What is going wrong here?

How can I solve this?

Thanks,
Miguel

What encoding did you set for the pages? Set the responseEncoding to "utf-8"

Check this link on how to set it in the web.config filehttp://msdn2.microsoft.com/en-us/library/hy4kkhe0(vs.80).aspx

Thanks

Strange Characters in Asp.Net Text Box

Hello,
I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as
"=E7=E3=E1=E0=E9=ED" when I load the data again I get a few strange charact=
ers:
"=C3=A7=C3=A3=C3=A1=C3 =C3=A9=C3"
What is going wrong here?
How can I solve this?
Thanks,
MiguelHello shapper,
This seems like a flaw in Unicode encoding mode in your URL If the character
s
you have types are unicode, then make sure that you save the file in proper
Unicode mode. If you are using VS2005, then you will find a command 'Advance
d
Save Options' which does this.
Thanks
Cyril Gupta
-- You can do anything with a little bit of 'magination.
-- I've been programming so long, my brain is now software.

> Hello,
> I have a form which saves some data to an SQL 2005 database
> If the text written in the text box contains characters such as
> "" when I load the data again I get a few strange characters:
> "??á é"
> What is going wrong here?
> How can I solve this?
> Thanks,
> Miguel

Strange Characters in Asp.Net Text Box

Hello,

I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as
"" when I load the data again I get a few strange characters:
"??á é"

What is going wrong here?

How can I solve this?

Thanks,
MiguelHello shapper,

This seems like a flaw in Unicode encoding mode in your URL If the characters
you have types are unicode, then make sure that you save the file in proper
Unicode mode. If you are using VS2005, then you will find a command 'Advanced
Save Options' which does this.

Thanks
Cyril Gupta

-- You can do anything with a little bit of 'magination.

-- I've been programming so long, my brain is now software.

Quote:

Originally Posted by

Hello,
>
I have a form which saves some data to an SQL 2005 database
If the text written in the text box contains characters such as
"" when I load the data again I get a few strange characters:
"??á é"
What is going wrong here?
>
How can I solve this?
>
Thanks,
Miguel

Monday, March 26, 2012

Strange danish letters bug.

Hello,
I have a web site and i use some danish text on some of the page.
The letters appear as expected when i view the site with the VS 2005 built
in web server.
When i deploy the site either by XCOPY or as precompiled on win 2k3 IIS 6,
then i loose my danish chars.
can someone tell me how i can best deal with this problem.
many thanks in advance
JJOn 13 Feb, 10:15, "Jens Jensen" <j...@.jensen.dk> wrote:
> Hello,
> I have a web site and i use some danish text on some of the page.
> The letters appear as expected when i view the site with the VS 2005 built
> in web server.
> When i deploy the site either by XCOPY or as precompiled on win 2k3 IIS 6
,
> then i loose my danish chars.
> can someone tell me how i can best deal with this problem.
> many thanks in advance
> JJ
Are you including charset="UTF-8" in your html headers? Might be the
browser not interpreting the encoding correctly, so if you set it
explicitly it could work (alternatively, ISO-88591 should also be a
suitable encoding for Danish).
Tobes
> Are you including charset="UTF-8" in your html headers? Might be the
> browser not interpreting the encoding correctly, so if you set it
> explicitly it could work (alternatively, ISO-88591 should also be a
> suitable encoding for Danish).
> Tobes
>
Hi Tobes, that is an interesting detail. Can you give an example of where i
need to write this?
I'm using a master page.
Thanks
JJ
I tried the following :
<head runat="server">
<title>Untitled Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-88591"/>
</head>
<head runat="server">
<title>Untitled Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
non of them seems to help

Strange danish letters bug.

Hello,
I have a web site and i use some danish text on some of the page.
The letters appear as expected when i view the site with the VS 2005 built
in web server.
When i deploy the site either by XCOPY or as precompiled on win 2k3 IIS 6,
then i loose my danish chars.

can someone tell me how i can best deal with this problem.

many thanks in advance
JJOn 13 Feb, 10:15, "Jens Jensen" <j...@.jensen.dkwrote:

Quote:

Originally Posted by

Hello,
I have a web site and i use some danish text on some of the page.
The letters appear as expected when i view the site with the VS 2005 built
in web server.
When i deploy the site either by XCOPY or as precompiled on win 2k3 IIS 6,
then i loose my danish chars.
>
can someone tell me how i can best deal with this problem.
>
many thanks in advance
JJ


Are you including charset="UTF-8" in your html headers? Might be the
browser not interpreting the encoding correctly, so if you set it
explicitly it could work (alternatively, ISO-88591 should also be a
suitable encoding for Danish).

Tobes
Are you including charset="UTF-8" in your html headers? Might be the

Quote:

Originally Posted by

browser not interpreting the encoding correctly, so if you set it
explicitly it could work (alternatively, ISO-88591 should also be a
suitable encoding for Danish).
>
Tobes
>


Hi Tobes, that is an interesting detail. Can you give an example of where i
need to write this?
I'm using a master page.

Thanks
JJ
I tried the following :
<head runat="server">

<title>Untitled Page</title>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-88591"/>

</head>

<head runat="server">

<title>Untitled Page</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

</head>

non of them seems to help

strange ERROR

Hi..

Can any one tell me what is the following error mean and what is its reason?

Error 1 Validation (ASP.Net): Text is not allowed between the opening and closing tags for element MultiView'.

Please help me because it is appear to me in many pages.

Thanks..

The<asp:MultiView> control is a container for a group of<asp:View> controls. insert your contents in MultiView using <asp:View>

<asp:MultiView id="value" Runat="Server" ActiveViewIndex="viewindex"
<asp:View id="value1" Runat="Server"

...insert yourControls, text, and HTML

</asp:View>

<asp:View id="value2" Runat="Server"

...insert yourControls, text, and HTML

</asp:View>
...

</asp:MultiView>


I do exactly what you say but the error is not removeCrying


Please post the block of code pointed to by this error.


Hi..

This is the code:

<%@.PageLanguage="C#"MasterPageFile="~/Administration/AdministrationMasterPage.master"AutoEventWireup="true"CodeFile="UpdateStudentPayment.aspx.cs"Inherits="Administration_UpdateStudentPayment"Title="???????????????????????????"%><asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"> <divalign=center> <asp:ScriptManagerid="ScriptManager1"runat="server"> </asp:ScriptManager> <br/> <asp:UpdatePanelid="UpdatePanel1"runat="server"UpdateMode="Conditional"> <contenttemplate><asp:MultiViewID="MultiView1"runat="server">//Here is the error <asp:Viewid="View1"runat="server"> <strong><spanstyle="font-size: 24pt"><spanstyle="font-size: 20pt; color: #228b22"></span></span></strong> <asp:LabelID="Label14"runat="server"Text="Label"></asp:Label><br/> <br/> <SPANstyle="COLOR: red"><SPANstyle="FONT-SIZE: 24pt; COLOR: #228b22"></SPAN> <asp:Labelid="Label1"runat="server"Text="?????????:"ForeColor="ForestGreen"Font-Bold="True"></asp:Label> <asp:TextBoxid="TextBox1"runat="server"></asp:TextBox> <BR/> <asp:RegularExpressionValidatorid="RegularExpressionValidator2"runat="server"Font-Bold="True"ValidationExpression="^\d*"ErrorMessage="?????????????????????????? ..."ControlToValidate="TextBox1"></asp:RegularExpressionValidator><BR/> <asp:Labelid="Label9"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label><br/> <BR/><asp:Buttonid="Button1"onclick="Button1_Click1"runat="server"ToolTip="????????????"Width="105px"Text="??????????"ForeColor="ForestGreen"Font-Bold="False"Font-Size="Large"></asp:Button><BR/><BR/> <asp:DetailsViewid="DetailsView1"runat="server"Width="460px"Height="50px"ForeColor="#333333"Font-Bold="True"OnLoad="DetailsView1_Load"OnDataBound="DetailsView1_DataBound"OnDataBinding="DetailsView1_DataBinding"GridLines="None"DataSourceID="SqlDataSource1"DataKeyNames="StudentPaymentID"CellPadding="4"AutoGenerateRows="False"> <FooterStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></FooterStyle> <CommandRowStyleBackColor="#D1DDF1"Font-Bold="True"></CommandRowStyle> <EditRowStyleBackColor="#2461BF"></EditRowStyle> <RowStyleBackColor="#D8F3D0"CssClass="leftToRight"></RowStyle> <PagerStyleBackColor="#2461BF"ForeColor="White"HorizontalAlign="Center"></PagerStyle> <Fields> <asp:BoundFieldDataField="StudentPayment_UserID"SortExpression="StudentPayment_UserID"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="UserName"SortExpression="UserName"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldReadOnly="True"DataField="StudentPaymentID"InsertVisible="False"SortExpression="StudentPaymentID"HeaderText="????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="TotalPrice"SortExpression="TotalPrice"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaidMoney"SortExpression="PaidMoney"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="ReminderMoney"SortExpression="ReminderMoney"HeaderText="????????????? "> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaymentDtae"SortExpression="PaymentDtae"HeaderText="?????????? "> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> </Fields> <FieldHeaderStyleBackColor="#C5E9B9"Font-Bold="True"></FieldHeaderStyle> <HeaderStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></HeaderStyle> <AlternatingRowStyleBackColor="White"></AlternatingRowStyle> </asp:DetailsView> <asp:SqlDataSourceid="SqlDataSource1"runat="server"SelectCommand="SELECT StudentPayment.*, users.UserName, StudentPayment.StudentPayment_UserID AS Expr1 FROM StudentPayment INNER JOIN users ON StudentPayment.StudentPayment_UserID = users.UserID WHERE (StudentPayment.StudentPayment_UserID = @.UserID)"ConnectionString="<%$ ConnectionStrings:dbconn%>"> <SelectParameters> <asp:ControlParameterControlID="TextBox1"Name="UserID"PropertyName="Text"/> </SelectParameters> </asp:SqlDataSource><BR/><asp:Labelid="Label3"runat="server"Text="?????????????????????????"ForeColor="Red"Font-Bold="True"></asp:Label> <asp:Labelid="Label7"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <asp:Labelid="Label4"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <asp:Labelid="Label11"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label><BR/><BR/> <asp:Labelid="Label2"runat="server"Text="?????????????????????????? :"ForeColor="ForestGreen"Font-Bold="True"></asp:Label> <asp:TextBoxid="TextBox2"runat="server"OnTextChanged="TextBox2_TextChanged"></asp:TextBox><BR/><BR/> <asp:RegularExpressionValidatorid="RegularExpressionValidator3"runat="server"Font-Bold="True"ValidationExpression="^\d*"ErrorMessage="?????????????????????????? ..."ControlToValidate="TextBox2"></asp:RegularExpressionValidator><BR/><BR/> <asp:Labelid="Label12"runat="server"Text="Label"Font-Bold="True"></asp:Label><BR/><BR/> <asp:Buttonid="Button2"onclick="Button2_Click"runat="server"ToolTip="????????????"Width="75px"Text="????????????"ForeColor="ForestGreen"Font-Size="Large"></asp:Button> <asp:Buttonid="Button3"runat="server"ToolTip="????????????"Width="81px"Text="????????????"ForeColor="ForestGreen"Font-Size="Large"PostBackUrl="~/Administration/Students.aspx"></asp:Button> </SPAN> <STRONG><SPANstyle="FONT-SIZE: 24pt"><BR/></SPAN></STRONG> </asp:View> <asp:Viewid="View2"runat="server"><BR/> <asp:Labelid="Label5"runat="server"Visible="False"Text="????????????????????????"ForeColor="Red"Font-Bold="True"></asp:Label> <SPANstyle="COLOR: red"></SPAN> <asp:Labelid="Label8"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <SPANstyle="COLOR: red"></SPAN> <asp:Labelid="Label6"runat="server"Visible="False"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <asp:Labelid="Label10"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <SPANstyle="COLOR: red"></SPAN> <SPANstyle="COLOR: forestgreen"><SPANstyle="COLOR: red"></SPAN><BR/></SPAN> <asp:LabelID="Label15"runat="server"Text="?????????????????????????????????? "></asp:Label> <SPANstyle="COLOR: #333333"><BR/></SPAN><BR/> <asp:DetailsViewid="DetailsView2"runat="server"Width="460px"Height="50px"ForeColor="#333333"Font-Bold="True"GridLines="None"DataSourceID="SqlDataSource1"DataKeyNames="StudentPaymentID"CellPadding="4"AutoGenerateRows="False"> <FooterStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></FooterStyle> <CommandRowStyleBackColor="#D1DDF1"Font-Bold="True"></CommandRowStyle> <EditRowStyleBackColor="#2461BF"></EditRowStyle> <RowStyleBackColor="#D8F3D0"CssClass="leftToRight"></RowStyle> <PagerStyleBackColor="#2461BF"ForeColor="White"HorizontalAlign="Center"></PagerStyle> <Fields> <asp:BoundFieldDataField="StudentPayment_UserID"SortExpression="StudentPayment_UserID"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="UserName"SortExpression="UserName"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldReadOnly="True"DataField="StudentPaymentID"InsertVisible="False"SortExpression="StudentPaymentID"HeaderText="????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="TotalPrice"SortExpression="TotalPrice"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaidMoney"SortExpression="PaidMoney"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="ReminderMoney"SortExpression="ReminderMoney"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaymentDtae"SortExpression="PaymentDtae"HeaderText="??????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> </Fields> <FieldHeaderStyleBackColor="#C5E9B9"Font-Bold="True"></FieldHeaderStyle> <HeaderStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></HeaderStyle> <AlternatingRowStyleBackColor="White"></AlternatingRowStyle> </asp:DetailsView><asp:SqlDataSourceid="SqlDataSource2"runat="server"SelectCommand="SELECT StudentPayment.*, users.UserName, StudentPayment.StudentPayment_UserID AS Expr1 FROM StudentPayment INNER JOIN users ON StudentPayment.StudentPayment_UserID = users.UserID WHERE (StudentPayment.StudentPayment_UserID = @.UserID)"ConnectionString="<%$ ConnectionStrings:dbconn%>"> <SelectParameters> <asp:ControlParameterControlID="TextBox1"Name="UserID"PropertyName="Text"/> </SelectParameters> </asp:SqlDataSource><BR/><asp:HyperLinkid="HyperLink1"runat="server"ToolTip="????????????????????? "Font-Bold="True"NavigateUrl="~/Administration/Students.aspx">?????????????????????</asp:HyperLink></asp:View> <BR/> <asp:Viewid="View3"runat="server"><STRONG><SPANstyle="COLOR: #333333"><BR/> <asp:LabelID="Label16"runat="server"Text="??????"></asp:Label> <SPANstyle="COLOR: red"> </SPAN></SPAN></STRONG> <asp:Labelid="Label13"runat="server"Text="Label"ForeColor="Red"Font-Bold="True"></asp:Label> <STRONG><SPANstyle="COLOR: #333333"><SPANstyle="COLOR: red"> <asp:LabelID="Label17"runat="server"Text="????????????????? .."></asp:Label></SPAN><BR/> <asp:DetailsViewid="DetailsView3"runat="server"Width="460px"Height="50px"ForeColor="#333333"Font-Bold="True"GridLines="None"DataSourceID="SqlDataSource3"DataKeyNames="StudentPaymentID"CellPadding="4"AutoGenerateRows="False"> <FooterStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></FooterStyle> <CommandRowStyleBackColor="#D1DDF1"Font-Bold="True"></CommandRowStyle> <EditRowStyleBackColor="#2461BF"></EditRowStyle> <RowStyleBackColor="#D8F3D0"CssClass="leftToRight"></RowStyle> <PagerStyleBackColor="#2461BF"ForeColor="White"HorizontalAlign="Center"></PagerStyle> <Fields> <asp:BoundFieldDataField="UserName"SortExpression="UserName"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="StudentPayment_UserID"SortExpression="StudentPayment_UserID"HeaderText="?????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="StudentPayment_PaymentID"SortExpression="StudentPayment_PaymentID"HeaderText="????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="TotalPrice"SortExpression="TotalPrice"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaidMoney"SortExpression="PaidMoney"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="ReminderMoney"SortExpression="ReminderMoney"HeaderText="?????????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> <asp:BoundFieldDataField="PaymentDtae"SortExpression="PaymentDtae"HeaderText="??????????"> <ItemStyleHorizontalAlign="Right"/> <HeaderStyleHorizontalAlign="Right"/> </asp:BoundField> </Fields> <FieldHeaderStyleBackColor="#C5E9B9"Font-Bold="True"></FieldHeaderStyle> <HeaderStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></HeaderStyle> <AlternatingRowStyleBackColor="White"></AlternatingRowStyle> </asp:DetailsView> <asp:SqlDataSourceid="SqlDataSource3"runat="server"SelectCommand="SELECT StudentPayment.*, users.UserName, StudentPayment.StudentPayment_UserID AS Expr1 FROM StudentPayment INNER JOIN users ON StudentPayment.StudentPayment_UserID = users.UserID WHERE (StudentPayment.StudentPayment_UserID = @.UserID)"ConnectionString="<%$ ConnectionStrings:dbconn%>"> <SelectParameters> <asp:ControlParameterControlID="TextBox1"Name="UserID"PropertyName="Text"/> </SelectParameters> </asp:SqlDataSource><BR/><asp:HyperLinkid="HyperLink2"runat="server"ToolTip="????????????????????? "NavigateUrl="~/Administration/Students.aspx">?????????????????????</asp:HyperLink><BR/></SPAN></STRONG> </asp:View><BR/> </asp:MultiView></contenttemplate><triggers><asp:AsyncPostBackTriggerControlID="Button1"EventName="Click"></asp:AsyncPostBackTrigger></triggers></asp:UpdatePanel> <br/> <br/> <br/> <br/> <br/> </div></asp:Content>


Sorry for that appearance

Thursday, March 22, 2012

strange inconsistency referencing controls in Formview itemtemplate

Can anyone explain why in the following code, where btnCancel1 is a
Button inside the itemTemplate of the formview, the first call to
change the text of the button, in the Page_Load sub, works fine, but
the second call, in the bookFormView_ItemUpdated sub, throws an
exception (Object reference not set to an instance of an object)? And
if you know why, can you suggest a workaround?

Here is the code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then
bookFormView.ChangeMode(FormViewMode.ReadOnly)
Dim cancelButton As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton.Text = "Cancel"
End If
End Sub

Protected Sub bookFormView_ItemUpdated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles
bookFormView.ItemUpdated
Dim cancelButton1 As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton1.Text = "Done"
End Sub

The line of code where the error occurs is cancelButton1.Text = "Done"

Thanks in advance.

-- NedFollowup: In researching this I came across a comment that only the
controls in the current mode are accessible; if the formview is in edit
mode then only the controls in the <edititemtemplateare accessible,
if in read-only mode then only the controls in the <itemtemplateare
accessible. This might explain this except that an update is supposed
to automatically return the formview to read-only mode, right? Or does
that happen later (after the formview_itemupdated() has terminated)?
So I tried explicitly changing the mode to read-only within the
itemupdated subroutine, but I still get the same error.

Hope someone can relieve my frustration.

-- Ned

Ned Balzer wrote:

Quote:

Originally Posted by

Can anyone explain why in the following code, where btnCancel1 is a
Button inside the itemTemplate of the formview, the first call to
change the text of the button, in the Page_Load sub, works fine, but
the second call, in the bookFormView_ItemUpdated sub, throws an
exception (Object reference not set to an instance of an object)? And
if you know why, can you suggest a workaround?
>
Here is the code:
>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then
bookFormView.ChangeMode(FormViewMode.ReadOnly)
Dim cancelButton As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton.Text = "Cancel"
End If
End Sub
>
Protected Sub bookFormView_ItemUpdated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles
bookFormView.ItemUpdated
Dim cancelButton1 As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton1.Text = "Done"
End Sub
>
>
>
The line of code where the error occurs is cancelButton1.Text = "Done"
>
Thanks in advance.
>
-- Ned


1) Why not just use the control's variable? If the control has an id of
btnCancel1 and it's marked runat="server", then just do btnCancel1.Text =
"Done"

2) Are you using master pages? Control ID's change when placed into a
content placeholder on a master page. Use the DevToolBar to explore the DOM
and determine what your control's ID actually is on the client size.

"Ned Balzer" wrote:

Quote:

Originally Posted by

Can anyone explain why in the following code, where btnCancel1 is a
Button inside the itemTemplate of the formview, the first call to
change the text of the button, in the Page_Load sub, works fine, but
the second call, in the bookFormView_ItemUpdated sub, throws an
exception (Object reference not set to an instance of an object)? And
if you know why, can you suggest a workaround?
>
Here is the code:
>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then
bookFormView.ChangeMode(FormViewMode.ReadOnly)
Dim cancelButton As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton.Text = "Cancel"
End If
End Sub
>
Protected Sub bookFormView_ItemUpdated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles
bookFormView.ItemUpdated
Dim cancelButton1 As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton1.Text = "Done"
End Sub
>
>
>
The line of code where the error occurs is cancelButton1.Text = "Done"
>
Thanks in advance.
>
-- Ned
>
>


1) When I try that, I get an error in Visual Web Developer 2005: "Name
'btnCancel1' is not declared." It is marked runat="server" but I think
the problem arises because it is buried within the formview, so it's
not a normal button control.

2) No, I am not currently using master pages.

-- Ned

William Sullivan wrote:

Quote:

Originally Posted by

1) Why not just use the control's variable? If the control has an id of
btnCancel1 and it's marked runat="server", then just do btnCancel1.Text =
"Done"
>
2) Are you using master pages? Control ID's change when placed into a
content placeholder on a master page. Use the DevToolBar to explore the DOM
and determine what your control's ID actually is on the client size.
>
"Ned Balzer" wrote:
>

Quote:

Originally Posted by

Can anyone explain why in the following code, where btnCancel1 is a
Button inside the itemTemplate of the formview, the first call to
change the text of the button, in the Page_Load sub, works fine, but
the second call, in the bookFormView_ItemUpdated sub, throws an
exception (Object reference not set to an instance of an object)? And
if you know why, can you suggest a workaround?

Here is the code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then
bookFormView.ChangeMode(FormViewMode.ReadOnly)
Dim cancelButton As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton.Text = "Cancel"
End If
End Sub

Protected Sub bookFormView_ItemUpdated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles
bookFormView.ItemUpdated
Dim cancelButton1 As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton1.Text = "Done"
End Sub

The line of code where the error occurs is cancelButton1.Text = "Done"

Thanks in advance.

-- Ned


Well, it doesn't make sense to me, but I found the suggestion somewhere
and tried it: calling bookformview.databind() before attempting to
reference the object, and the error went away. Problem is, the button
text is not being changed either.

Hmmmmmm

Ned Balzer wrote:

Quote:

Originally Posted by

1) When I try that, I get an error in Visual Web Developer 2005: "Name
'btnCancel1' is not declared." It is marked runat="server" but I think
the problem arises because it is buried within the formview, so it's
not a normal button control.
>
2) No, I am not currently using master pages.
>
-- Ned
>
William Sullivan wrote:

Quote:

Originally Posted by

1) Why not just use the control's variable? If the control has an id of
btnCancel1 and it's marked runat="server", then just do btnCancel1.Text =
"Done"

2) Are you using master pages? Control ID's change when placed into a
content placeholder on a master page. Use the DevToolBar to explore the DOM
and determine what your control's ID actually is on the client size.

"Ned Balzer" wrote:

Quote:

Originally Posted by

Can anyone explain why in the following code, where btnCancel1 is a
Button inside the itemTemplate of the formview, the first call to
change the text of the button, in the Page_Load sub, works fine, but
the second call, in the bookFormView_ItemUpdated sub, throws an
exception (Object reference not set to an instance of an object)? And
if you know why, can you suggest a workaround?
>
Here is the code:
>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not Page.IsPostBack Then
bookFormView.ChangeMode(FormViewMode.ReadOnly)
Dim cancelButton As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton.Text = "Cancel"
End If
End Sub
>
Protected Sub bookFormView_ItemUpdated(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs ) Handles
bookFormView.ItemUpdated
Dim cancelButton1 As Button =
CType(bookFormView.FindControl("btnCancel1"), Button)
cancelButton1.Text = "Done"
End Sub
>
>
>
The line of code where the error occurs is cancelButton1.Text = "Done"
>
Thanks in advance.
>
-- Ned
>
>

Strange Issue egarding ASP:textbox control.

I have a form. I fill the text property of all the textboxes on the form to
display information to the user. If the user changes a value and clicks
save. I save the information to the database.
This sounds all well and good however the record does not get updated, in
fact I have traced it to the fact that the textbox.text property is not
being updated after the user changes the value.
Please, if you have experienced anything like this, please help. This is
very frustrating.That's not much information to go on but I suggest looking for something in
your onload that is rebinding or reloading the textbox with the original
data before you get to the click event of your save button. Remember that
onload is called before the button event.
Also, make sure you're only setting the value of the textbox from the
database when IsPostBack is false. If you're setting it in every case, you
will reset it before you get to the click event.
Good luck,
Dale
"Red" <wreyes@.optonline.net> wrote in message
news:OTvW$ONUEHA.2408@.tk2msftngp13.phx.gbl...
> I have a form. I fill the text property of all the textboxes on the form
to
> display information to the user. If the user changes a value and clicks
> save. I save the information to the database.
> This sounds all well and good however the record does not get updated, in
> fact I have traced it to the fact that the textbox.text property is not
> being updated after the user changes the value.
> Please, if you have experienced anything like this, please help. This is
> very frustrating.
>
Hey thanks alot. I can not beleive I made such a simple mistake. For days I
have been looking at everything accept for when I was displaying the data.
Anyway, thanks again.
"DalePres" <don-t-spa-m-me@.lea-ve-me-a-lone--.com> wrote in message
news:e05xBXNUEHA.2564@.TK2MSFTNGP11.phx.gbl...
> That's not much information to go on but I suggest looking for something
in
> your onload that is rebinding or reloading the textbox with the original
> data before you get to the click event of your save button. Remember that
> onload is called before the button event.
> Also, make sure you're only setting the value of the textbox from the
> database when IsPostBack is false. If you're setting it in every case,
you
> will reset it before you get to the click event.
> Good luck,
> Dale
> "Red" <wreyes@.optonline.net> wrote in message
> news:OTvW$ONUEHA.2408@.tk2msftngp13.phx.gbl...
> to
in
>

Strange Issue egarding ASP:textbox control.

I have a form. I fill the text property of all the textboxes on the form to
display information to the user. If the user changes a value and clicks
save. I save the information to the database.

This sounds all well and good however the record does not get updated, in
fact I have traced it to the fact that the textbox.text property is not
being updated after the user changes the value.

Please, if you have experienced anything like this, please help. This is
very frustrating.That's not much information to go on but I suggest looking for something in
your onload that is rebinding or reloading the textbox with the original
data before you get to the click event of your save button. Remember that
onload is called before the button event.

Also, make sure you're only setting the value of the textbox from the
database when IsPostBack is false. If you're setting it in every case, you
will reset it before you get to the click event.

Good luck,

Dale

"Red" <wreyes@.optonline.net> wrote in message
news:OTvW$ONUEHA.2408@.tk2msftngp13.phx.gbl...
> I have a form. I fill the text property of all the textboxes on the form
to
> display information to the user. If the user changes a value and clicks
> save. I save the information to the database.
> This sounds all well and good however the record does not get updated, in
> fact I have traced it to the fact that the textbox.text property is not
> being updated after the user changes the value.
> Please, if you have experienced anything like this, please help. This is
> very frustrating.
Hey thanks alot. I can not beleive I made such a simple mistake. For days I
have been looking at everything accept for when I was displaying the data.

Anyway, thanks again.

"DalePres" <don-t-spa-m-me@.lea-ve-me-a-lone--.com> wrote in message
news:e05xBXNUEHA.2564@.TK2MSFTNGP11.phx.gbl...
> That's not much information to go on but I suggest looking for something
in
> your onload that is rebinding or reloading the textbox with the original
> data before you get to the click event of your save button. Remember that
> onload is called before the button event.
> Also, make sure you're only setting the value of the textbox from the
> database when IsPostBack is false. If you're setting it in every case,
you
> will reset it before you get to the click event.
> Good luck,
> Dale
> "Red" <wreyes@.optonline.net> wrote in message
> news:OTvW$ONUEHA.2408@.tk2msftngp13.phx.gbl...
> > I have a form. I fill the text property of all the textboxes on the form
> to
> > display information to the user. If the user changes a value and clicks
> > save. I save the information to the database.
> > This sounds all well and good however the record does not get updated,
in
> > fact I have traced it to the fact that the textbox.text property is not
> > being updated after the user changes the value.
> > Please, if you have experienced anything like this, please help. This is
> > very frustrating.

strange label quirk upon a postback

Have a page page1.aspx that has a label1 with text properties set say arial with font size of "large" there is a button on Page1.asp that upon its click event triggers javascript to open another window Page2.aspx. This causes a postback to occur on Page1.aspx as Page2.aspx is opened. If I dismiss Page2.aspx label1 on Page1.aspx has changed to a much larger font that previously set??? Now if I delete lable1 and place another label on the Page1 form and do not set any font properties the issue does not occur ...the font, it remains unchanged. Seems in a labels default mode, when first dragged on a webform the font properties are not set...at least this seems apparently so when viewing them in the properties window.

Anyone have any ideas...strange behaviour that seems to have no apparent answer...yet

Thanks

So you're saying the label's styling changes afterpostback? Is there another class or some style attribute beingassigned to the label, or something (like a span or table) thatsurrounds the label?

Ifwe could see the page in action, we might have a better idea of what'sgoing on; have you tried View Source to see if anything looks differentin the HTML?


As far as I beleive, check the style sheet. You might be applying dynamic style to that particular label. Try changing the name of the label and execute the same code.

Tuesday, March 13, 2012

Strange problem setting focus on a TextBox within a WizardStep.

For testing purposes i have got a 2 step WizardControl. Eqach step contains
a text box, TextBox1 and TextBox2 respectively. If i put the following code
in the respective activate event handlers for the two steps,

TextBox1.Text ="foo";

and

TextBox2.Text = "bar";

Then in the first step the TextBox (TextBox1) contains the word foo and in
the second step the TextBox (TextBox2) contains the word bar. As you would
expect.

However if i replace the code with

TextBox1.Focus();

and

TextBox2.Focus();

Then i get the following error and i can't understand why. This is the
first time i have used Wizard controls and i'm just trying to work out how
they behave. What am i missing about Wizard controls that is causing this
behaviour.

A form tag with runat=server must exist on the Page to use SetFocus() or
the Focus property.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.InvalidOperationException: A form tag with
runat=server must exist on the Page to use SetFocus() or the Focus property.

Source Error:

Line 19: protected void WizardStep1_Activate(object sender, EventArgs e)
Line 20: {
Line 21: TextBox1.Focus();
Line 22:
Line 23: }

Source File:
E:\DevelopmentWebsite\IntranetDev\Portal\Testing\M ultiViewTest.aspx.cs
Line: 21

Stack Trace:

[InvalidOperationException: A form tag with runat=server must exist on the
Page to use SetFocus() or the Focus property.]
System.Web.UI.Page.SetFocus(Control control) +2021658
System.Web.UI.Control.Focus() +20
Testing_MultiViewTest.WizardStep1_Activate(Object sender, EventArgs e) in
E:\DevelopmentWebsite\IntranetDev\Portal\Testing\M ultiViewTest.aspx.cs:21
System.Web.UI.WebControls.View.OnActivate(EventArg s e) +105
System.Web.UI.WebControls.MultiView.set_ActiveView Index(Int32 value) +395
System.Web.UI.WebControls.MultiView.OnInit(EventAr gs e) +46
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.AddedControl(Control control, Int32 index) +2065279
System.Web.UI.ControlCollection.Add(Control child) +146
System.Web.UI.WebControls.Wizard.CreateControlHier archy() +2992
System.Web.UI.WebControls.Wizard.CreateChildContro ls() +126
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692On further investigation it seems that i can't set the focus on any control
from within the activate event. I have no problems however, setting the
focus onto the textbox controls within the wizardsetps, from the Page_load
event

"clickon" wrote:

> For testing purposes i have got a 2 step WizardControl. Eqach step contains
> a text box, TextBox1 and TextBox2 respectively. If i put the following code
> in the respective activate event handlers for the two steps,
> TextBox1.Text ="foo";
> and
> TextBox2.Text = "bar";
> Then in the first step the TextBox (TextBox1) contains the word foo and in
> the second step the TextBox (TextBox2) contains the word bar. As you would
> expect.
> However if i replace the code with
> TextBox1.Focus();
> and
> TextBox2.Focus();
> Then i get the following error and i can't understand why. This is the
> first time i have used Wizard controls and i'm just trying to work out how
> they behave. What am i missing about Wizard controls that is causing this
> behaviour.
> A form tag with runat=server must exist on the Page to use SetFocus() or
> the Focus property.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information about
> the error and where it originated in the code.
> Exception Details: System.InvalidOperationException: A form tag with
> runat=server must exist on the Page to use SetFocus() or the Focus property.
> Source Error:
> Line 19: protected void WizardStep1_Activate(object sender, EventArgs e)
> Line 20: {
> Line 21: TextBox1.Focus();
> Line 22:
> Line 23: }
>
> Source File:
> E:\DevelopmentWebsite\IntranetDev\Portal\Testing\M ultiViewTest.aspx.cs
> Line: 21
> Stack Trace:
> [InvalidOperationException: A form tag with runat=server must exist on the
> Page to use SetFocus() or the Focus property.]
> System.Web.UI.Page.SetFocus(Control control) +2021658
> System.Web.UI.Control.Focus() +20
> Testing_MultiViewTest.WizardStep1_Activate(Object sender, EventArgs e) in
> E:\DevelopmentWebsite\IntranetDev\Portal\Testing\M ultiViewTest.aspx.cs:21
> System.Web.UI.WebControls.View.OnActivate(EventArg s e) +105
> System.Web.UI.WebControls.MultiView.set_ActiveView Index(Int32 value) +395
> System.Web.UI.WebControls.MultiView.OnInit(EventAr gs e) +46
> System.Web.UI.Control.InitRecursive(Control namingContainer) +321
> System.Web.UI.Control.AddedControl(Control control, Int32 index) +2065279
> System.Web.UI.ControlCollection.Add(Control child) +146
> System.Web.UI.WebControls.Wizard.CreateControlHier archy() +2992
> System.Web.UI.WebControls.Wizard.CreateChildContro ls() +126
> System.Web.UI.Control.EnsureChildControls() +87
> System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
> System.Web.UI.Control.InitRecursive(Control namingContainer) +321
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692

Strange problem setting focus on a TextBox within a WizardStep.

For testing purposes i have got a 2 step WizardControl. Eqach step contains
a text box, TextBox1 and TextBox2 respectively. If i put the following code
in the respective activate event handlers for the two steps,
TextBox1.Text ="foo";
and
TextBox2.Text = "bar";
Then in the first step the TextBox (TextBox1) contains the word foo and in
the second step the TextBox (TextBox2) contains the word bar. As you would
expect.
However if i replace the code with
TextBox1.Focus();
and
TextBox2.Focus();
Then i get the following error and i can't understand why. This is the
first time i have used Wizard controls and i'm just trying to work out how
they behave. What am i missing about Wizard controls that is causing this
behaviour.
A form tag with runat=server must exist on the Page to use SetFocus() or
the Focus property.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information abou
t
the error and where it originated in the code.
Exception Details: System.InvalidOperationException: A form tag with
runat=server must exist on the Page to use SetFocus() or the Focus property.
Source Error:
Line 19: protected void WizardStep1_Activate(object sender, EventArgs e)
Line 20: {
Line 21: TextBox1.Focus();
Line 22:
Line 23: }
Source File:
E:\DevelopmentWebsite\IntranetDev\Portal
\Testing\MultiViewTest.aspx.cs
Line: 21
Stack Trace:
[InvalidOperationException: A form tag with runat=server must exist on the
Page to use SetFocus() or the Focus property.]
System.Web.UI.Page.SetFocus(Control control) +2021658
System.Web.UI.Control.Focus() +20
Testing_MultiViewTest.WizardStep1_Activate(Object sender, EventArgs e) in
E:\DevelopmentWebsite\IntranetDev\Portal
\Testing\MultiViewTest.aspx.cs:21
System.Web.UI.WebControls.View.OnActivate(EventArgs e) +105
System.Web.UI.WebControls.MultiView.set_ActiveViewIndex(Int32 value) +395
System.Web.UI.WebControls.MultiView.OnInit(EventArgs e) +46
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.AddedControl(Control control, Int32 index) +2065279
System.Web.UI.ControlCollection.Add(Control child) +146
System.Web.UI.WebControls.Wizard.CreateControlHierarchy() +2992
System.Web.UI.WebControls.Wizard.CreateChildControls() +126
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
System.Web.UI.Control.InitRecursive(Control namingContainer) +321
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Control.InitRecursive(Control namingContainer) +198
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692On further investigation it seems that i can't set the focus on any control
from within the activate event. I have no problems however, setting the
focus onto the textbox controls within the wizardsetps, from the Page_load
event
"clickon" wrote:

> For testing purposes i have got a 2 step WizardControl. Eqach step contai
ns
> a text box, TextBox1 and TextBox2 respectively. If i put the following co
de
> in the respective activate event handlers for the two steps,
> TextBox1.Text ="foo";
> and
> TextBox2.Text = "bar";
> Then in the first step the TextBox (TextBox1) contains the word foo and i
n
> the second step the TextBox (TextBox2) contains the word bar. As you woul
d
> expect.
> However if i replace the code with
> TextBox1.Focus();
> and
> TextBox2.Focus();
> Then i get the following error and i can't understand why. This is the
> first time i have used Wizard controls and i'm just trying to work out how
> they behave. What am i missing about Wizard controls that is causing this
> behaviour.
> A form tag with runat=server must exist on the Page to use SetFocus() or
> the Focus property.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information ab
out
> the error and where it originated in the code.
> Exception Details: System.InvalidOperationException: A form tag with
> runat=server must exist on the Page to use SetFocus() or the Focus propert
y.
> Source Error:
> Line 19: protected void WizardStep1_Activate(object sender, EventArgs
e)
> Line 20: {
> Line 21: TextBox1.Focus();
> Line 22:
> Line 23: }
>
> Source File:
> E:\DevelopmentWebsite\IntranetDev\Portal
\Testing\MultiViewTest.aspx.cs
> Line: 21
> Stack Trace:
> [InvalidOperationException: A form tag with runat=server must exist on the
> Page to use SetFocus() or the Focus property.]
> System.Web.UI.Page.SetFocus(Control control) +2021658
> System.Web.UI.Control.Focus() +20
> Testing_MultiViewTest.WizardStep1_Activate(Object sender, EventArgs e)
in
> E:\DevelopmentWebsite\IntranetDev\Portal
\Testing\MultiViewTest.aspx.cs:21
> System.Web.UI.WebControls.View.OnActivate(EventArgs e) +105
> System.Web.UI.WebControls.MultiView.set_ActiveViewIndex(Int32 value) +3
95
> System.Web.UI.WebControls.MultiView.OnInit(EventArgs e) +46
> System.Web.UI.Control.InitRecursive(Control namingContainer) +321
> System.Web.UI.Control.AddedControl(Control control, Int32 index) +20652
79
> System.Web.UI.ControlCollection.Add(Control child) +146
> System.Web.UI.WebControls.Wizard.CreateControlHierarchy() +2992
> System.Web.UI.WebControls.Wizard.CreateChildControls() +126
> System.Web.UI.Control.EnsureChildControls() +87
> System.Web.UI.WebControls.Wizard.OnInit(EventArgs e) +100
> System.Web.UI.Control.InitRecursive(Control namingContainer) +321
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Control.InitRecursive(Control namingContainer) +198
> System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692
>