I have a rich textbox which contains data loaded in from a database. I want to change the functionality of the rich textbox to ensure that data can only be written to it by a user and not deleted from it.
Of course, making the rich textbox read only won't help, nor will not enabling it. I'm stuck for ideas
With only one RichTextBox, you can't. What you have to do is instead of working with one RichTextBox, you could have two. Use one to show the data from database, and use another with editing enabled for the user to submit new data. something like how forum handle posts.
You can have the original content loaded from the database displayed in a label and have a separate textbox in which the user can add new content. On save you will concatenate the db content with the text from the textbox and save it back to the DB. This way you can only add and not remove from the original copy.
Related
I have an Asp.NET form. On page load, I am populating text boxes and drop down lists.
When the user clicks on the edit button, I want to know if the user changed the values or selected a new value but then re-selected the old value and didn't actually change anything.
I can think of two methods:
Create hidden labels for each input and then track in code behind.
Use session state or re-query the source where I uploaded the data from in the first place.
Do you know any better way?
you can use a stringbuilder
At page load you can put all values in stringbuilder now create a another stringbuilder in that put changes values or values after button editing of records completed
After that you can compare two string
or you can store those strings in database for future reference
I want to get CSV file values in my C# form controls.(TextBox, NumericUpDown,ListBox)
I have one list say Names and one button Load
When i click load button values in CSV like Name,Age,RollNo.
should be added in List Box with Name field and on click of Name from ListBox
Values for Name,Age,Roll No should be shown in TextBox and NumericUpdown.
Plz help i am new to C#......
As you're new to C# (and by the way you phrased your question, new to programming in general) I think writing a CSV parser by yourself might be asking too much - fortunately there are libraries to do this for you. Just read through this article: http://www.codeproject.com/Articles/9258/A-Fast-CSV-Reader which contains a link to the code you can download and include in your project.
NumericUpDown isn't a "data" control - it just lets the user select a single value from a range of numbers. I can't see how you could use that control in the context of data from a CSV file (unless the control is to edit a single field value in a single row of a CSV file, of course).
Everything else you've described sounds like simple event-based programming. Just wire-up a handler for the ListBox.SelectedIndexChanged event and populate your form from there.
I'm trying to highlight the selected text contents by the user inside the HTML page.I have highlited the text using jquery (dot net). Now I need to save some information to the database that makes me able to highlight the same contents again for future loads of the same page, taking care of all inner elements that the text could have inside.
i.e.,
Have a base HTML files thats same for every user, given the freedom to user to highlight content in provided page, after he highlites, information needs to saved to database against each user, so that when user open the same html file again,(HTML files shown in a panel) he gets the same page with the highlighing he had done earlier.
Please suggest what information should I save to database..
any pointer how would I move ahead..
Thanks in advance your help.
not a dot net expert , but it seems like you are storing content in database, when fetching they need to be highlighted.
the best way is save content as html or write you own highlight tag
and then replace it to blank when highlight not needed , and replace it with
<div style="background-color:red"> to highlight.
Hope you are getting the approch.
And if you are using HTML files , then it is always better to store them in database. String manuplation for every request will be much heavy task to do.
i want ask about control label or link
i have label in home page
and I want change this label content from admin page
how to control and change it?
you want a sort of content management system, try saving this label in some datasource (xml or database) and then use it where required.
More details would be good. You want to be able to have an admin page where you have an input form that allows you to set content on the home page? If so, there are a few ways to do that. One way is to use a database to store the content, and then load from database on the home page. Another way is to store data in the HttpContext object, this however is not persistent.
You'll want to the display text from some sort of dynamic source, such as a database, xml file, flat file, etc. In the admin page, you write to that data source and load the text for the source from that source as well.
I want my users to be able to enter text in a Rich Text box and the RTF output be saved to the database.
Currently I have the RichTextBox bound to the field in the database, but it strips formatting when it's saved. How can I prevent this?
Also, how can I attach a formatting toolbox, (like what's in Wordpad) so my users can change the formatting?
And, last, I can't right click in the box or use Ctrl+C, Ctrl+V or anything like that, why is that? How can I fix it?
Ok, there are alot of questions there, I'll try to answer what I can.
1) Databinding is great for displaying data, but I personally NEVER use DataBinding for saving stuff back to the database. I've always found it to be "too much magic happening" and that I needed more control. Therefore, I would strongly suggest that you handle the insertion yourself (via LINQ to Sql or ADO.Net whatever). The RichTextBox control has an RTF property which you can get to do the insert manually into the database.
2) As for getting formatting buttons on top, it's not as simple as changing a property and be done with it. You'll have to implement that custom control yourself. Have a look at this CodeProject article. IT's in VB.NET, but maybe it'll give you some ideas: http://www.vbdotnetheaven.com/UploadFile/scottlysle/WordProcessor09122006234320PM/WordProcessor.aspx
3) Not quite sure...
For number 3, isn't there a property on the RichTextBox that enables the Context menu? I might've seen this on a different control but maybe it also has that property.