Hi I've a problem with the property .SelectedText.
I've Microsoft Visual Web Developer Express 2008 - Framework version: 3.5.
The problem is that Visual Studio can not find this property, I also checked that there were any dll.
Property. SelectedText is in the System.Windows.Controls namespace right?
I don't know where wrong, please help me!
Here is the msdn page from which I copied the code:
It would seem that you are confusing two entirely different things. If you are developing for the web, the TextBox you are probably using comes from the namespace System.Web.UI.WebControls. That control does not have a SelectedText property. You should confirm that you are linking in the correct namespace.
Notice the namespace referenced at the top of the article you linked: System.Windows.Controls. That means it is written using Windows Presentation Foundation (WPF), not ASP.Net. In web browsers, WPF is implemented through Microsoft Starlight, which is basically a subset of WPF merged with AJAX. This lets you preserve user states, such as what the user has selected in a text box. Normal ASP is built on the HTML protocol which is stateless: postbacks are handled by sending a hidden form, which gives the information (text in a textbox) but no metadata (what part of that text is selected.) That is why the standard ASP controls do not have properties like SelectedText.
I don't think you can do what you want to do using ASP. WPF and Silverlight has a lot of very interesting and useful functionality, but there is a bit of a learning curve. You could try posting your question in the Web Development or Silverlight forums, but it might be better to either figure out a different way to get what you want, or buckle down and learn a new programming tool. Unfortunately, I've not had the time to learn it myself, so I'll just shut up now.
I'm not sure where the problem might be, but you can rewrite this a bit to help with the debugging.
Dim Obj AsObject = lvPTRPhoneCalls.FindControl("IDNOInsertLabel")
If Obj IsNotNothingThenDim Lbl As Label = TryCast(Obj, Label)
If Lbl IsNotNothingThen
Lbl.Text = lblSelectedIDNO.Text
Else'Do something to report the errorEndIfElse'Do something to report the errorEndIf
With this, you can see if the control is not being found, or if it is found but is not a label.
Google gave me this explaination for the error:
the problem is actually caused by the critical http header parsing/validating
of the HttpWebRequest component. According to the Http
Specification(http1.1), the HTTP header keys shoud specifically not include
any spaces in their names. However, some web servers do not fully respect
standards they're meant to. Applications running on the Dotnet framework
and making heavy use of http requests usually use the httpWebRequest class,
which encapsulates everything a web oriented developer could dream of. With
all the recently issues related to security, the "httpWebRequest" class
provides a self protection mechanism preventing it to accept HTTP answers
which not fully qualify to the specifications.
The common case is having a space in the "content-length" header key. The
server actually returns a "content length" key, which, assuming no spaces
are allowed, is considered as an attack vector (HTTP response split
attack), thus, triggering a "HTTP protocol violation error" exception.
Do you have a reason you don't want to use an update panel?
Your question is like asking about getting a nail into a piece of wood but refusing to use a hammer. When you make silly restrictions with no reasons behind them you are less likely to get help because you might dismiss other good solutions for no apparant reason as well.
Of course. A nail doesn't require a hammer either. You could use a rock. And you can just pick up a rock without the overhead of a mining and smelting operation for the metal part of a hammer. But if I have a hammer and a rock on my work table, I am probably going to use the hammer. And if someone comes into my workshop and declares "no hammers allowed" for no apparant reason I will dismiss them as a nut and tell them to go away.
The overhead is usually minimal when compared to the complexity and maintainability issues of most of the alternatives for someone who is new to ASP.Net as the asker stated.
But we can let the asker decide. The following article discusses some of the trade-offs and alternate methods. UpdatePanel Tips and Tricks[^]
Last Visit: 31-Dec-99 19:00 Last Update: 2-Dec-23 21:02