implement filter using static variable - novice - asp.net

I have an HTML textbox where a user types some text and then the entries matching the text are retrieved from the database. I store this filter string value in a static string variable because I need to use its value somewhere in the program.
the question is: will all users currently logged in end up with the same filter result and overwrite their own filters every time they do a change.

Related

User Picker to field values

Sorry if this is too basic for this site, but app maker help directed me here. I am creating a data entry screen that includes basic info for a user - name, email, phone, etc. I am using the user picker to select the individual from our Directory. How do I pass all of the needed Directory field values of the selected user to my insert record screen. I am checking the valueisRecord box on the user picker, but can't figure out how to assign the selected user's info to the form's value fields. Thanks for the help.
Ok, your last comment makes sense. But please, to avoid going back and forth, I encourage you to formultae your question properly by including all the information that could be required. Now, moving on to your problem...
The reason you are getting that error is because you are binding the UserPicker widget value to the datasource email field. Remember, the UserPicker value is an object, not a string.
To fix your problem, remove the binding of the value from the UserPicker. Then for the onValueChange change event of the UserPicker please add the following:
var fullName = newValue.FullName;
var email = newValue.PrimaryEmail;
widget.datasource.item.Name = fullName
widget.datasource.item.email = email;
That way, you don't assing an object to the email field but instead a plain string.

how can I input and display the data via the database quickly?

I have a webpage in which users input some data and that data is supposed to be stored in the database and then at the same moment should be displayed in the display section.
I have a very trivial question please. How can I take the result from the database to be displayed the same moment the user inputs it in the database? Is it like something cronjob, which checks the database every second that the new results have been input or not?
e.g. I have a registration form to register the properties in a property webpage. if a user submits a form to my database, how can I keep checking whether the database is updated or not? The users would expect their property listing to be displayed on the webpage within a second

How can I change field values to be inserted in the asp.net membership creation

I want to insert user name as unique mail ID and for the mail field in the registration process I want to use the same mail id to be inserted in the asp.net membership user table but by now it was creating user it's own but now I want to change it how can I achieve this ?
I am writing on page load
MembershipCreateStatus creatStatus;
Membership.CreateUser(RegisterUser.UserName, RegisterUser.Password,
RegisterUser.UserName, RegisterUser.Question,
RegisterUser.Password,
true, MembershipCreateStatus.ProviderError);
// true, creatStatus);
Is it correct? But it throws error invalid argument.
What should I do for last two arguments?
First, the last parameter is an out parameter. This means that CreateUser will set the variable you specify, you can't pass in a status enumeration like you are doing there.
Instead, you have to do it like the code you commented out, except you have to specify out creatStatus (including the out keyword).
Second, invalid argument typically means one of the values is null.

ASP.NET Site architecture issue

Due to the nature of the way the website I am working on was designed I have an issue I now must resolve.
I will try to write this question as language-independent but the site is done in ASP.Net with C#.
Overview
The structure of our site looks like this for any given "object":
ASPX Page
Multiple UserControls (ascx pages)
Textboxes, Comboboxes, Labels,
Buttons, etc.
What this means is, if we have a User page and that page might have 3 UserControls. One for User Information (Name, email, etc.), one for Address (City, State, Zip, etc.) and one for Regional Settings (Time zone, language, etc.)
All of these fields on the 3 UserControls are all stored in the same table in the database.
Now, we are using DataBinding and EntityFrameworks to fill in the data and this means that when we save an object, we are actually calling save 3 times (1 per UserControl).
(Language-Agnostic: We don't actually
assign values like User.Name =
"Bob", it is handled by a Framework)
Because the UserControl only knows about the fields it contains, when the Databinding saves it "thinks" the other fields are now blank. (i.e. Address control saves and now "Email" and "Name" are null values). To "fix" this there is a method called "MapOldToNew" which goes out and grabs the old record and fills in the values on the New object that is about to be saved. This is generic, which means we don't have a method on the Address Usercontrol that says "go get the Name and Email fields and fill them in", instead it loops through all the properties of the Entity(object) and if a value is NULL on the New object but NOT NULL on the Old object (the one currently in the database about to be overwritten) it will make the New value equal to the Old value.
The Problem
Dates. We allow NULL dates in our database.
If a User fills in "Birthday" and saves, they now have a Birthday value in the field in the database.
If they go back and clear out the Birthday field on the web page and save, the MapOldToNew method grabs the old record, sees that Birthday is not null there and is Null on the New object about to be saved, it will override the New value (NULL) with the Old value ('7/23/1981' for example).
Solutions?
Rework our system to not use
UserControls but instead have all
controls on the same Page, thereby
reducing the number of times we need
to Save and not requiring
MapOldToNew. For now, let's
assume this is an impossible
solution (even though it is the one
I feel like should be done for
plenty of reasons).
Store all
dates as Strings and do conversion
on Load and Save. (Strings don't
have the same problem because once a
string has been modified it is now
an empty string, and not NULL)
Do not allow NULL dates in the
database and always store
DateTime.MinValue and do not
display it On Load.
Those are the ideas I have come up with off the top of my head. For arguments sake, let's assume #1 is not possible (because I have a feel management won't like the time it will take to accomplish).
How would you "fix" this?
Another Explanation
Here is the problem broken down more.
User Record has 2 fields. Name and Birthdate.
Assume that there is 1 ASPX Page with 2 UserControls (ascx).
UserControl1 has a single DatePicker DataBound to "BirthDate".
UserControl2 has a single TextBox DataBound to "Name".
When UserControl1 calls Update on the ObjectContext the User object it sends looks like this:
{ Name = NULL, BirthDate = 8/13/1980 }
MapOldToNew looks at the Database Record and sees that Name should be "Bob" so it fills the value in and the record saves.
UserControl2 calls Update now and the User object looks like this:
{ Name = "John", BirthDate = NULL }
MapOldToNew sees that BirthDate is NULL so it overwrites it with 8/13/1980 from the database and the record saves and the database has the correct values.
Now assume the user goes back in and deletes the BirthDate value. When UserControl2 calls MapOldToNew, it sees that BirthDate is NULL (which the user wants) and overwrites it from the Database.
If it DIDN'T overwrite it from the database, it would always save it as NULL and the user would never be able to set the BirthDate.
I would refactor MapOldToNew to understand nullable types. Im assuming you have a nullable date (for ex. datetime? or Nullable and if so - do not make the assumption of overwriting if null.
Also in the future consider MVC or for WebForms consider Dynamic Data because of the mapping of types to models.
http://aspnet.codeplex.com/wikipage?title=Dynamic%20Data

How to pass values from one .aspx to another

I have a user id by using query string and i want to retrieve other data directly from the database(i dont want to use query string {}& name={}..like that further) anybody can help me pl.. i am beginner
If you don't want to use querystring than you can use session or a property in the page which you can set from the calling page.
Pijush

Resources