If it's possible it would be a great thing.
So is there a way how to achieve somehow a ViewState behavior into a WinForm's Application.
Like if i have a Bunch of TextBoxes ,than uses types text into them ,TextBoxes should store Their Text ,Location ,Size etc. and on Next Application Startup they should Load their Content Text ,Location ,Size etc.
Further...every Control into every Form ,should store Their State somehow ,and on Load ,they should Load their Content and Other Properties like they where last time Application was running.
PS : If there is not any Library or already made Solution ,than please don't try to spend time writing Code ,because it's not Fear to ask you guy's for Code ,i need just Direction's and Ideas because i plan to achieve it by my-self.Down-Voter's please consider that!!!
Using my google-fu I found this on code project.
The guy's written some code that effectively serializes a form out to XML so you can load it back in again. Don't know if it would cope with forms with dynamic controls that perhaps aren't on the form when you load it back in again - but I'm sure you can tweak the code to do what you want.
Related
In our current application there is a new requirement of our client.As they told that they need n numbers of forms at different stages of their business and those are changing time to time. Even a new forms can be added. Their requirement is once the product is delivered to them they will not come back to us again and again for each change and will create those form by their own.
Simply they want a user interface where they can create the form by drag and drop manner.
What they want :
In our application there will be a form building section where a non technical person can be able to create a form.
Mapping the controls with existing data of their existing database so that the form is populated with the corresponding data ( data will be inserted into the database using another user interface).
Once the data is populated they will take the print out of the filled up form and will proceed as per their business flow.
As they introduce new form time to time we can't provide any predefined template to them and they are not agree to design the form in HTML.
Is there any way of doing this in Asp.Net MVC (without using any CMS ).
there are a number of asp.net forms builders. And I been wanting to build my own for years. (you store the control, the location etc in a database, or even as xml, and then on page load, read the xml, and crank out the controls and layout into the page. We all built these for desktop, and you can do the same for the web.
The open source evolutility project has a FANTASTIC system for this, but it does NOT include the GUI part. But, it would be a good start. You would have to build the GUI part, but the rendering part, and save of the forms layout is all done for you. So, your forms builder would offer a set of controls to drop and move around in the form. When you save, you would have a corresponding "xml" markup bit that you save to the one "forms layout" file. On forms load, you read that xml file and produce the form (that's the part evolutility does for you). So, you need the part that has each control in a tool box (along with the xml for that control). you drop control into form, and add the xml to the "form layout in xml".
As I stated, evolutility has all the parts to render forms and layout and place controls on the final finished form for display - it just don't have a GUI for doing this part.
You can look at the project here:
http://evolutility.com/
there are others. But, it really depends on how complex of a form builder or content builder you wish to make.
But, a xml, or json based layout and definition of the controls placed on a page is a good start. You could store such "layout" information in a database. Heck have a classic master to child table, and thus save each control in evolutiity format, and simple append then all together, and then have evolutility render that xml into a working form for you.
I don't know of a open source project that combines both the "layout" and "define" of the controls AND ALSO has a GUI to build the forms. But, to be fair, the hard part (how to layout, and how to have each control defined in some json (or xml) is done for you.
I have a bit of data stored in a file that I would like to display on a Razor Page in my project. The obvious thing to do would be to just read the file in the .cshtml.cs file, pass it in the model, and display it. That, or caching.
The file, however, won't change often (if at all), and any time it would change, would be accompanied by the code of the app itself changing, so a build would be necessary one way or another.
That's how I got the idea of somehow generating the desired HTML on build time.
I know that, on build time, .cshtml files are compiled into regular C#, and I was looking for a way to, perhaps, hook into this process somehow. Alas, without much success.
My other attempt was a .razor file, rendered in a Static way, with data fetched in ObInitializedAsync() which was supposed to run only once per component. However, I think that hosting this component in a Razor page interfered with it somehow, and the code was running on every page load. That, or I misunderstood the lifecycle in the first place.
I even went as far as making a .cs-only component and manually using the RenderTreeBuilder from an overridden BuildRenderTree, but it also seems to render per page load.
Lastly, I briefly considered using a source generator to create a partial, but alas, source generators can't read files, so that attempt also failed.
I'm, quite frankly, out of ideas at this point. Hence the question, perhaps someone else had the same issue, or knows something I don't.
im building something like a macro in mine "JitBit Macro Recorder".
I can make some cool stuff there and there is an option to use C# language. I have made a lot of this macro but I'm stuck.
I need a simple C# script to read a number dynamically loaded by javascript on webpage and save it to clipboard - that's it.
I can see in the source it's coded like this (there is dynamically loaded number in the place of "-"):
<span id="counting">-</span>
I hope it's not too much to ask. I know I'm not providing mine own C# code - it's because I don't know this language and it's usually not needed in Macro Recorder but this time it gave me headache.
Greetings!
I do not think you can do this. Javascript only happens in the browser and C# happens in a different process. At least the number is contained in the source code of the page you will not be able to access to it.
You can try with your browser "inspect element" feature since it can access its own memory and it can tell you how the Javascript is being loaded and what variables are there. But to do it with your script you would need to hack into the browser memory address with some kind of debugger. Tricky.
I've searched the web for 2 days now and am about to give up on this, but I'm soo close to the final solution... so you're my last hope. ;)
I have made a little C# application with Windows Forms GUI that uses a webBrowser element to display an HTML file with a TinyMCE editor embedded - this way I get a nice window with customizable editor functions I can use perfectly for my needs in this project.
I can set the textarea input for this editor window without problems thanks to this solution posted here on stackoverflow: https://stackoverflow.com/a/16322324/3498545
However I'm having big troubles reading text from this textarea. If I read the element by ID as shown (for setting content) in the solution above, I get the old text, as TinyMCE never really saves the changes.
But how do I get the input that my users will make in the textarea via TinyMCE? Is there some way to trigger a form send in HTML to get this input?
Thank you so much for you help!
Ok, to answer my own question (maybe others find this useful sometime later):
The changes of TinyMCE don't get written back to the textarea field in realtime, so I had to work around that. One solution would be to add something in the javascript header that writes every change back to the textarea immediately, however this caused problems for me as TinyMCE code clean up is not involved at this point.
My solution was to temporarily create a new file where the input of the TinyMCE field gets written directly into source code, which is a piece of cake to read back in C#.
The javascript code needed looks like this:
setup : function(editor){
editor.on('submit', function (){
tinymce.triggerSave();
document.writeln("<!DOCTYPE html><html><body><div id='content'>"+document.getElementById('textarea').value+"</div></body></html>")
document.close()
});
}
After that you can read the content in C# with the following code:
webBrowser.Document.GetElementById("content").InnerHtml
Now I can store HTML formatted code in my SQL database that can be managed and edited with a shiny interface. ;)
I'm trying to design my C# winform application with a very generalized function to automatically go through all of the form elements and save their states/values in a text file so that I can load it later. I want it to be very generalized so that it'll be a cinch to reuse this code in future projects, as it wouldn't be heavily tied down to the specifics.
The form elements I want to save are text boxes, combo boxes, data grid views, list boxes and that's about it. I want to save their values and everything about them.
One way that I was going about it was to go through every possible form element and then detect eachs type, and then create the corresponding c# code to re-create its value ('tboxmine.value="blue elephant"'), and then writing the code to a file, so that I could load the code from the file and execute it using the CSCcompiler. My code so far doesn't seem to be working correctly and I'm having my doubts that this compiler is actually running the code inside my application (I think it's possibly creating a new thread?), and it just seems like there's probably a far more straightforward relatively standard way of doing this.
This seems a bit like the reverse "best practice" approach. If you dont't know about databinding I suggest you look into that.
Basically you create classes to represent your data and use databinding to associate controls with your objects. The controls will automatically show the right value and allow the user to change it. If the user has changed the value, your object gets automatically updated.
To save the data, you would use some kind of serialization to store your objects in a file. When loading, you let the Serializer rebuilt your class structure and (best case) you are good to go.
This is not exactly what you asked for, but I think it is something you could use well ;-)
N.B.: Not the complete state of the control is saved. e.g. in a Textbox your text would be saved but the BackColor won't.
To get you started look into this tutorial: http://www.codeproject.com/Articles/24656/A-Detailed-Data-Binding-Tutorial