Showing posts with label write. Show all posts
Showing posts with label write. Show all posts

Saturday, March 31, 2012

Text box

Hello can anybody write me how to clear text from texbox after I click on button

Hi

on Button's Click event (after you've read the Text) set

[VB]
TextBox1.Text = ""

[C#]
TextBox1.Text = "";

assuming your TextBox's ID isTextBox1


Use something like this in the click event handler of the button:

TextBox1.Text = "";

(where TextBox1 is the ID of your text box)

Regards,
Martin


This method: TextBox1.Text = ""; is not fast, because you make request on server ,optimal use JavaScript on ClientMachine:function f(){tbx.value="";}

Wednesday, March 28, 2012

Text field property

I have a text field i nmy app. If I write "10" in the text field and close the app, then I reload the application and when I focus on the text field I can see all prior entered valued in this text field in a list. I don't like that! How do I prevent this? Is there a property to the textbox which "cleans" the list?i dont know why this would be happening, and im no expert.
i believe it is you own settings in internet explorer

tools
internet options
content
auto complete
:ehh:
This is what I mean:
yes , i believe that is your own setting of internet exploroer.
i.e. if you type in googles search bar, are you greeted with the same drop down list qith ll your previous searches...
Ok, I was not aware of this. Now I have changed the mark in Autocomplete under Forms and everything is ok. But I have to inform all of my users of this :-(
it may be it can be programmed but i am unaware of how,,
perhaps the pragma no cache or something may help,
may be worth a googling if no expert gets back to you here
I don't think this can be changed programmatically. I for one like the feature :D

Monday, March 26, 2012

Text files, reading,writing and saving

Hi,

I want a textbox on my site, you write in it and click save

the text is then saved as 'sample.txt'

then I also want that page to OPEN 'sample.txt' and read the contents into a textbox

I just want the simplest way of doing this

can someone point me at the code

thanks

Seethis tutorial which does what you ask.

yes, that answered it

thanks!


AHHH... looks like the right code however...

got a couple of textboxes and buttons

I pasted this code from the tutor into the code area of a button

System.IO.StreamReader StreamReader1=new System.IO.StreamReader(Server.MapPath("test.txt"));TextBox2.Text= StreamReader1.ReadToEnd();StreamReader1.Close();
it says: streamreader is a type in IO and cannot be used as an expression
it also says streamreader is not declared.
im using basic not C is that the problem?

Yes, the tutorial is in C#, not VB. For a VB tutorial trythis page.

yes the code example is written in C

however im using basic

visual web developer express

anyone know how to read write and save a file ...simply

it seems as though I can't use streamreader...there is no help on it in web developer express.


thanks for your help.Geeked

To read.. there's a great new addition to the System.IO namespace and that's "ReadAllText"

So you'd say

Text1.Text = System.IO.File.ReadAllText(Server.MapPath("~/sample.txt"))

and that's it!

For writing, the above links that everyone else is fine... 3 lines using the StringWriter class... and never ever forget to ".Dispose" the object otherwise it will lock the file


You've probably worked this out by now , but I wrote a little tutorial the other day that does exactly this, it over here if you're still intrestedwww.codeproject.com

Text in asp:TextBox

I'm having some trouble with my Asp:TextBox (a multiline actually). I want to write some text in it, so I use the expression "NameOfTextBox.Text='Some text'". Unfortunatly 'Some text' is converted to HTML (for example: < is automaticly converted to &lt;).

I want to take care of any html-conversion myself. Is there a way to tell the textbox, that I want it to contain the the text without modifications?I'm not understanding where the conversion is taking place. I have a simple page below that loads a string into textbox and shows it as I've set it. Of course, it's impossible to actuallyshow that in this forum (grrr), but basically I'm setting the text to "< b >Hello< /b >" (no spaces in the tags. It shows the < and > characters in the text box. Is that what you mean?

<%@. Page Language="VB" %>
<script runat="server">
Sub Page_Load()
textbox1.text = "Hello "
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
</form>
</body>
</html>

I will make myself a bit clearer. If I use the code-line:

textbox1.text = "<"

I want the HTML generated to be something like this:

<textbox id=textbox1><</textbox>

As it is now, the result will be:

<textbox id=textbox1><</textbox>

The text is in some way automatically encoded to be displayed as proper HTML. I have problem, 'cause I use Swedish characters as ö and that is automatically encoded to &ouml;. See my problem?
The encoding of < into < in a textbox is normal and conforms to the HTML standard AFAIK.
The TextBox control automatically encodes the text. To get the proper ö, just set the text to a normal string with the special character to avoid double encoding:
simply writing textbox1.Text = "ö" will produce the desired character.

Does this help?
It works with writing just textbox1.Text = "ö", but the problem is that the text to be displayed is already encoded. The text is taken from a file, which has all its text in HTML-format. If there is no way to tell the textbox to display the proper text, is there a way to decode the html into text again (make ö into ö and so on)? If not, I think there are some other (complicated) ways to solve it.
You can try HttpUtility.HtmlDecode.
HttpUtility.HtmlDecode may be what I'm looking for. Thanks.

Thursday, March 22, 2012

text writing security worries

Hi,

I'm writing an application to load, edit and save xml with a flash7 front-end using .net scripts to write the xml.

Here's the script I'm using to save the xml:

private void Page_Load(object sender, System.EventArgs e){

String fileUrl;
String xmlData;
String returnToFlash;

fileUrl = Request.Form["fileUrl"];
xmlData = Request.Form["xmlData"];

StreamWriter sr = File.CreateText(Server.MapPath(fileUrl));
sr.WriteLine(xmlData);
sr.Close();

returnToFlash = "data=Success";
Response.Write(returnToFlash);

}

It's pretty simple, which is why I'm worried about the possibility of people 'spoofing' it with false data that hasn't come from my flash app.

There is a login script too which will (eventually) check the user credentials against a database to allow access. I was thinking that perhaps I should send these login credentials when saving a file to authenticate the user. Although I'm pretty sure there must be a better way to do it - ideally I don't want users to poll the database more than once per session.

This must be a problem that flash developers face all the time, I just haven't been able to find any articles on the topic (as I don't fully understand what I'm looking for!)

So my question is: What is the best way to secure access to this script without sending a username and password to check a database?

ThanksIt's a scary proposition when you are going to allow files to be uploaded to a web server. You should develop a strategy that allows you to upload files to a directory that only has Write permissions for the ASPNET/Network Service account as you want to prevent anyone from uploading an executable and being able to execute it.

That said, there is alot to security and this situation. I recommend you check out "Improving Web Application Security" and "Building Secure ASP.NET Applications".
I didn't consider the ASPNET/Network Service account permissions. They have already been set for me by hosting company for the directory I'm writing to. Perhaps this is enough?
Thanks for the links, I'll give them a read.

Tuesday, March 13, 2012

TextBox and calendar

Hello,
When i have a textbox, in which i want to write a date, i want to call the calendar control.
How can i do it?I suggest you download and install the Timetracker Starter Kit. It uses an example with a Pop-Up Calendar Control. When you choose a date and press OK, the date is written to the Textbox Control in the original document. The Starter Kit in itself is also very useful.
Hi,

you can also take a look at thiscontrol.

Grz, Kris.
Hello, although that control is nice and cool. But maybe its better our friend go a little bit into depth and see how such things are implemented. Check this article please, it will give you a wide knowledge of how that can be done:

Populating Form Inputs Using the Calendar Control

Regards.
Hi Haidar,

great aricle you provided. When I've got to some free time to spare I'll read it myself.

Grz, Kris.
Hello Kris, glad you liked that article. You know something, I always like to read about things and not move directly to code. Sometimes, you feel certain issues need no more than some pieces of code. But the rest of time, I prefer to go in depth with techniques, so that you pass by it once and then the next time, you alread have the idea behind it so you won't waste a lot of time knowing how to do it. But if you always just check the code, you would never learn it and every time you would spend the same amount of time to solve it.

regards.
thanks
Glad to help my friend. Good Luck.

regards.
Hi,

this can be accomplised by Java Script. Search google.com for making pop up calender in asp.net
Check out this code sample on how to change the dates of the ASP.Net Calendar:
http://www.aspnet101.com/aspnet101/aspnet/codesample.aspx?code=calChange