Get the values of a dynamically created textbox in c# [closed] - c#

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have searched a lot for this and found a bunch of things that might help, but i a, cannot implement them in my code, and b, its not exactly what i need for my code.
Essentially, i am looking to have an inventory update web form. When you get to the page, there is one drop down list, and based on which item you select (add inventory, remove inventory) different options appear on the page.
That being said, im trying to dynamically create different fields based on the autopostback dropdown list, and i have the fields appearing fine. However, i cannot get any values that i need.
For example, whenever i try to set
theText = textBox1.Text
it comes up null.
would this be easier with java script or am i just missing something?
thanks

Though your questions is extremely vague because nobody knows what your code looks like or where it is, when dealing with dynamically created controls there are two guidelines to keep in mind:
All controls should be created and added to the page in the Page_Load so that the events and properties can be set via ViewState.
When accessing properties, they need to be accessed outside of the Page_Load because the values would not yet be available as they have not been bound. You would need to grab these values in an event like PreRender.

If you know the ID of the dynamic control you can find it with Page.FindControl():
http://msdn.microsoft.com/en-us/library/31hxzsdw.aspx

Related

pass objects in WPF XAML [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I am new to coding GUI stuff, and I was wondering if anyone could tell me whether there is a way to pass objects in xaml to the constructor of another FrameworkElement.
Right now, I am using the code-behind to send an object that does not derive from any of the allowed types in XAML. However, If I were to make the class being passed derive from frameworkElement as well, would it be possible to pass it as an object to a constructor or perhaps set a field to it?
for example
or can properties only be normal value types and is there no way to use constructors beside the default one?
As I said I am currently just passing stuff to the constructor in the C# file that goes with the xaml, but I feel like it would be convenient if it were possible to pass with xaml.
Your doing it wrong.
Unless you are writing a real "user control" There should be very little logic in your view code behind or view constructor. Instead almost all of the logic should be in either View Model or Model types that get into your view through data binding.
This of course isn't always 100% possible, in which case the 'Field' you are looking for is called DataContext. You can set this to an object and then subscribe to the DataContextChanged event and do whatever view specific logic you need there.
see http://msdn.microsoft.com/en-us/magazine/dd419663.aspx among others for more.

create a wizard [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to implement a wizard using winforms and VS 2010.
I've got this tutorial, but as I'm new to Visual Studio and C# I don't really understand it.
Could someone help me out?
My main problem is that I don't know where to put the listings in this tutorial?
Should I put all the code in one class? Or in one form.cs? How is it divided?
greetz
Bl!tz
It looks as if you will need to create a UserControl (right-click your project, New... User Control) for each page of the Wizard, and you will need to implement IWizardPage on your UserControl. Than you have your WizardHost which is a single Form.
So to answer your question you will have one Form and a UserControl for each page of the Wizard.
This is a simple example, use groupboxes, and set them all on visibility hidden, but only show the first one, then when u click the button u set the visibility of the first groupbox to hidden, and the set the visibility of the 2e one to show.
a groupbox can contain controls, so that u wont have to show or hide individual controls

Issues related with Wpf [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am new to wpf and i am working on first application i have some issues related with this
1.)Control allignment : My controls when set on the page is seem ok but when i run my application controls slightly change their position.
2.)Resolution Issue : When i try to run application on the machine with different resolutions some controls become invisible.
3.)Bind combobox :When i try to bind combobox with static or dynamic combobox items i am not able to get first item on page load for eg if i have a city combobox then i want to show "Select City" on page load.
Thanks in advance
WPF has its own alignment system that differs from those in WinForms and HTML. Be sure to study the issue before doing any markup - trust me, you will just lose time.
WPF is resolution independent - it's one of the most essential of its features. The problem should be related to the 1st one.
Could you provide additional info so that I can figure out what exactly are you trying to accomplish?
There are lots of resources on WPF. I would recommend visiting Wpf Tutorial. And for more serious reading Pro WPF in C# 2010 (by Matthew MacDonald) is great.
1 & 2) As EvAlex says, WPF has it's own alignment system using various Panel types. These grow and shrink content to take advantage of the available space and resolution.
You appear to be dragging controls onto the form in DevStudio, which is adding all those Margin="323,182,0,0" properties to you markup. This is effectively hardcoding an absolute position for your controls which is generally a bad idea.
3) You cannot set text in a WPF combo unless it is in the list of items or you have set IsEditable="True".
Read some of the tutorials that EvAlex posted. You need to get a good grasp of the basic ideas before jumping in. WPF does have a fairly steep learning curve.

How to read a specific number from a HTML page [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
for example , if I wanted to set the Index value from this page:
http://ca.finance.yahoo.com/q;_ylt=Agfc5O8HHTlOLgX.q6V4HEtyzJpG;_ylu=X3oDMTFkdnZqMHBkBHBvcwMyBHNlYwN5ZmlNYXJrZXRTdW1tYXJ5RnJvbnRwYWdlBHNsawNzcHRzeA--?s=^GSPTSE
to a variable, how can I do that??
I am VERY NEW to programming, I would really appreciate if you explained every line.
My point isnt to get it done, I want to understand it.
Thank you very much in advance!
If you look at the source code of the web page, you find that the index number is within a span tag which has a unique id: <span id="yfs_l10_^gsptse">13,702.33</span>.
This means that you can scrape the page and then single out that individual tag.
You need to start by connecting to the host and downloading the page. The way in which you do this depends on which language you're using. There are plenty of tutorials around - just search for "[language] web scraping".
Then you need to create a Document Object Model from the html source code - again, this depends on the language, it's easy in some and difficult in others. Once you've done that, simply search for the tag with an id of yfs_l10_^gsptse and grab the content.
Hope that helps - obviously there's a lot I haven't said, but it depends what language you want to use.

iTemplate what is it and place where i can get GOOD example in c# [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
HI ,
I am currently trying to learn more about custom controls and how to use them etc. i have come across iTemplate interface and was hoping that someone could better explain its use and point me toward a good example implementation. From what i have found it allows you to change how an asp.net control will display items. ive tried searching code project etc for a good example but none explain it well. Id ideally like a very basic example and a more complex one.
thanks
Niall
ITemplate: Defines the behavior for populating a templated ASP.NET server control with child controls. The child controls represent the inline templates defined on the page. (taken from MSDN).
Take a look at these great tutorials: Developing Custom ASP.NET Server Controls or Templated Server Control Example.

Categories