Reference Main Control from User Control - c#

I am using WPF to write an Application.
The Main window of the Application is called systemInfo.
In system Info I have a search user control and a tab control that has multiple tabs.
I have a System Entity that relates to every single one of the tabs. Using the System entity ID, the information is loaded into each tab after the Search control finds the entity.
My problem is, After the information is Loaded into the first tab, and another tab is clicked the "System Entity" and the "System Entity ID" disappear. Thus I am unable to load the information for that same Entity without searching again for the Entity.
I need a way to retain the "System Entity" and the "System Entity ID" information across all the tabs.
EDIT:
TO CLARIFY:
This is not an issue with the retrieval of the data. The Data is retrieved properly using a service that accesses the information in the SQL Server database.
The problem is in the XAML and the Forms that display the data. The first tab Loads initially with the information retrieved from the Database using the System Entity ID. The following tab loads based on that information. But when the Original Tab or any other tab is clicked. that ID is not retained it is lost and it can't retrieve the data because the ID does not exist.
I can't provide code because the code doesn't exist to handle this interaction. The Main Window is a container and all the other items (Tab content, Search Control) are User Controls.
Any help will be extremely appreciated.
thank you,
Sam

How are you storing your data? What codes are run when the tab is clicked (on the event).
I guess if you put some code over here that would help a lot to understand your problem.

Related

asp.net web form in multiple browser tabs

I have a grid view and an edit button in the grid view. On edit button click I am opening a new aspx page that has text fields for input the data. When a user copies the URL of the gridview and opens it in a new tab of any browser then click on the edit button for two different records. If the user changes anything in the first tab and submits it. It changes the info for the record on the second tab. It is happening because I am passing userid in session to the form aspx page and session got updated when user opens the second record in the new tab.
Are there only two ways to passing data to aspx page?
using session
using a query string
I don't want to use the query string.
Please help thank you.
You are writing a ASP.Net application, so at the end of the day there is only that much you can do. You can request some things off the browser, but if he actually does it is entirely up to it.
You can make it unlikely to happen by accident, using the HTML Links target property. This requests the browser to re-use any alread open tabs for this record. But that will not prevent a dedicated person from still opening 2 copies.
A pretty simple way to avoid race conditions in general, is the SQL rowversion column. You retreive the rowversion with the rest. You keep it along in a hidden formular field (that is what they are there for). When writing the update, check if it still matches before the write. If yes, you update. If not, somebody has modified the record since then and you reject the update. Can be the same user in another tab, can be another user at the end of the world. Could be that this tab was opened a year ago, surviving on sleep mode. It does not mater - any change trips this protection.

ASP.NET WebForms, DropDowns, Submit Button

I have struggled to find a solution to this problem through lots of Google searching and documentation reading, and even looking at others’ source code, but I am putting it here in the hopes that someone knows how to help me or has specific experience in dealing with such a thing.
I am currently working on an ASP.NET WebForms project with some of my colleagues, and we have decided to go with an option of which I was not a fan. We have created a page where the user will be required to fill out the university classes they have taken, with related data, in a massive sheet of dropdown menus.
These dropdown menus are pulling their associated data for the user to choose from the database (SQL Server, a.k.a. “Microsoft SQL”), as a way to partially limit user error. The user will make their selections on none, one, some, or multiple dropdowns from multiple “rows” on this page.
My question is how I can write an SQL Server query, and thus, stored procedure, that will allow for a “submit” or “save changes” button to be added to this page. When a user clicks this button, presumably, all of the changes that they have made on any of these “rows” – one row per class – will be added to the database for their respective user account.
My suggestion was having that page be an ASP.NET Grid View that would update with the classes that the user had taken as they entered them. There would be a button at the top of the page where the user could click “Add Class”, and they would be taken to a model popup or some other page, and they would enter the details of that class, mostly through predefined information that is pulled from the database. In the case of an administrator user, they would essentially be able to put whatever information in for the class, because they have the ability to override the strictly regulated format for regular (student) users.

Get previous webpage

I am at a loss as to how this is best handled in asp.net
I have a webpage with a lot of panels, and tables that is populated with data from mysql request. Now this data might change depending on an input. All the data are buttons that will open a modal windows displaying data.
My issue is that when I press the button the modal opens, but all the tables are reset to the standard "sql data" and the panels collapses. I basiclly want to be able to post back to the exact spot the user was earlier, including where on the page he had scrolled.
I get that the created html istanse is destroyed as soon as the person moved to the modal but how can i store the current exact state of the webpage so when the user goes back he is met with the exact "copy" he left. I've looked into viewstate and state management, and also to check for postback but still havent been able to solve it.
Is there any good tutorial covering this topic?
I've looked into this: Persisiting the state of a webpage
But thats based on ASP2.0 (im at 4.5) and dated 2006. Would this approach still be my best option or is this fixed in a better way on newer ASP.NET version?

Auto refresh databinded component after Database update

fellow devs! I need to know a strategy that will allow me to know that the database has been updated so that I can rebind respective controls (DropDownLists in this case. Here is a bit more details:
I have three Combo-Boxes (DropDownLists) on a MDI Parent form. Selecting a value from these combos will allow me to directly jump to the view form for the selected entity. Now, on MDI parent load, these combos are filled up. But once the application is running, anyone from anywhere can edit an entity or add a new one. i need to detect this and somehow cause the combo(s) to reload again.
Using Linq-2-SQL to load the Combos, Backend is a SQL 2005 DB on a SQL 2008 Server.
There's no builtin functionality to do all of this, so you'll have to roll your own.
One possibility I can see is to have a timer that periodically checks whether the items have been updated. You could do this by storing a last updated timestamp somewhere and checking against it. When you detect that the items changed, requery the data and rebuild the combos.
didn't try it, but you may take a look at the Sql Service Broker feature.
From my memory, it can create a file on the file system and you can monitor the creation of this file.
it's the feature used by the ASP.Net cache and its dependencies check.

Display gridview in new window

Just a bit of advice needed really in terms of how I should handle my current scenario:
I have a web page that searches for products/category information the results of which are at present displayed in a gridview on the same page.
However, said gridview is a bit of a beast and as such, I would like to have a page that the user searches for, a button is pressed and the subsequent gridview is displayed in a new window.
Ultimately, I would like the user to be able to make multiple searches so that new windows can have multiple gridviews containing different data sets.
My current thinking is to create session variables that can be pulled through onto 'the gridview page'. Having said that, I'm not sure that would work if multiple searches are created?
I am also thinking I might be able to create said 'gridview window' using javascript but my concern here is the potential loss of functionality of the gridview i.e. paging, sorting, editing, etc.
Does anyone have any thoughts or theories on this? What would be "best practise"? Any thoughts greatly appreciated and taken on board.
PS: This is being developed in .net, using c# and LINQ.
PPS: I'm a noob so be gentle!!
There is no need of sessions here right ? well on your first page where you enter search query, when user clicks on the button open the search result page in a new window with a query string may be search.aspx?keyword=foo.
so everytime user clicks on search button it keeps on opening new windows. u can javascript to open the new popup window and set "target" attribute to "Blank" so it will open in new window

Categories