Syntax To Change The Value Of A Cached Object Property?
Jun 6, 2010
In an ASP.NET 3.5 VB web app, I successfully manage to cache an object containing several personal details such as name, address, etc. One of the items is CreditNum which I'd like to change in the cache on the fly. Is there a way to access this directly in the cache or do I have to destroy and rebuild the whole object just to change the value of objMemberDetails.CreditNum?The cache is set using:
Public Shared Sub CacheSet(ByVal key As String, ByVal value As Object)
Dim userID As String = HttpContext.Current.User.Identity.Name
HttpContext.Current.Cache(key & "_" & userID) = value
End Sub
I'm new to ASP so this may seem so simple but I cannot work it out.
I am trying to create a script that changes its output based on a range of values. Here is what I mean:
I have a MSSQL database with an ASP scripted website that reads it and displays the data in a table. One of the columns in the database is a percentage and I want that column in the web page to have a background colour based on the figure outputted.
So each cell may be a different colour. If the number is between 0 and 30 then red background, 31 to 70 orange etc.
At the moment I have the database output script looking like this:
Traditionally with an Object Data Source, the wired up class will have its public properties available for binding (i.e. Gridview columns, etc.) which works well. But what if one of my wired up business objects has a property that is an object itself; can I drill down to a property on that object property and still use it?
So in additiona to the traditional:MyBusniessObject.OrderID...I want to use:MyBusniessObject.Customer.NameID Your 1st response might be to just wire up the 'Customer' class, but I need properties both on 'MyBusinessObject'and 'Customer'. I do not think this can be done, as the ODS will not display properties on an object instance property. I have tried manually typing in the drilled down value as well, but that wasn't a success either.
I am working on Vs2005 and asp.net 2.0. I have a solution with 4 projects (business object, components, data access, webclient)When I change any existing method or property in Business object or data access, it is not reflecting in the application. I have deleted the existing references to the project and added them after the new build. I always get errors like "method not found or No overload method "It seems like old verion of dll is still there in the reference.
I'm having an issue when using the Asp.Net Cache functionality. I add an object to the Cache then at another time I get that object from the Cache, modify one of it's properties then save the changes to the database.
But, the next time I get the object from Cache it contains the changed values. So, when I modify the object it modifies the version which is contained in cache even though I haven't updated it in the Cache specifically. Does anyone know how I can get an object from the Cache which doesn't reference the cached version?i.e.
Step 3: Item item = (Item)Cache.Get("test"); if(item.Title == "Test 1"){ Response.Write("Object has been changed in the Cache."); }
I realise that with the above example it would make sense that any changes to the item get reflected in cache but my situation is a bit more complicated and I definitely don't want this to happen.
I found some code on the web and it threw me off. Look at the code below. You will notice only when the Hits == 1, does the cache get added. After that, the cache object isn't updated. It begs the question, does the object when updated, update the cache as well automatically? The answer here would make me remove some code in some of my classes.
I am caching a file in ttpContext.Current.Application object. Now when I change the values in file, it does not get reflected in the application (I am reading the values from the file for app version).
Even after restarting the app pool and the website in IIS, the changes does not reflect. I dont want to restart IIS.
I want to update my cached data , if there is any change in database. , if any change in database/tables happens then my cached data should be updated.
'Person' is not a member of type 'Transient.rowtype[(Id,Edm.Int32(Nullable=True,DefaultValue=))]' in the currently loaded schemas.
Does the EntityDataSource not support walking the relationships? How would you do this with the EntityDataSource?
Also the @userName parameter is being added in the code behind for now. Extra points for anyone who knows how to specify a username parameter directly in the WhereParameters collection.
When are declared values bound to properties of a user control in WebForms?
I have a user control which has a public property which is an enum type. In my aspx page I'm setting it's value declaratively. In the ascx I'm outputting the value to the page using <%= %> syntax. The value that is output by the echo syntax is always zero 0. The enum does nopt have a zero value.
My question therefore is, is echo <%= %> syntax evaluated before the declared value is bound to the property?
I'm going to assume that zero is the "unset" value for any enum member and therefore assume that <%= is executed before the value is bound to the property.
What is the format for databinding to a complex "object"? I have a linq to sql class that has containment, i.e object.containedobject.I want to reference the sub objects fields declarative.So I've tried my MySubField.MyBasicProperty and that did not work, as well as, MySubField_MyBasicProperty.
I've generated an entity framework class to handle my users from a custom db table. Now I'd like to override the password property of the EF object to Encrypt the value when it is set. From what i understand of MVC this should be done in the model where the EF object lives. I am able to do this easily in the controller but that doesn't seem like the most appropriate place as it will lead to duplicate code anywhere that needs to edit this user class. Is extending the partial class generated from EF possible for generated DB column properties?
I have a scenario where and array consists of values of different types.
During runtime I need to cast the current index to its type to get its property value
for eg: I have an array events[100];
the current index events[i] could be of any type say TYPE1.The TYPE1 could have multiple properties.During runtime, while iterating, I need to get all the properties and values of TYPE1 by casting the events[i] to the specific type, which I form as xml string and pass to DB.I'm at loss what way of reflection would achieve this.
P.S: I dont know the property of current index at runtime, which is why I'm collecting all the properties and dumping in DB.
What is the value of SomeId after I create an instance of my object? I was testing it with SomeId == 0 but it wasn't working. Then I tried null which gives me an error.
What is the right way to handle this? Am I to assign an initial value to my objects' properties in the object? If not, how do check if my object has any values assigned to its properties -- in particular, int values?
have a table releases with release id and release name and the child table as Sprint. But I am getting an exception while the page loads saying the property or object name release id couldnt be found
public partial class Default2 : System.Web.UI.Page
I'm currently using a GridView and I want to set the CssClass for the Row depending on a property of the object that the row is being bound to.
I tried the following but it does not work (see comments):
[code]...
Now I could simply handle the GridView's RowDataBound event and change the css class of the row there...but I'm trying to keep a clear separation between the UI and the page/business logic layers.
I am trying to get an asp:SessionParameter of a SelectParameters, to use a property of an object in session instead of having a string in the session like Session["CustomerID"]
Something like Session["Customer"] where the property is ((Customer) Session["Customer"]).CustomerID)
My code:
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:DBConnectionString %>" xmlns:asp="#unknown"> SelectCommand="SELECT * FROM getStoreCustomers (@customerID,@week,@day)" ProviderName="System.Data.SqlClient"> <selectparameters> <asp:sessionparameter name="customerID" sessionfield="Customer" /> ?????? (what is the syntax to pass the property here?) <asp:controlparameter controlid="ddWeek" defaultvalue="-1" name="week" propertyname="SelectedValue" /> <asp:controlparameter controlid="ddDay" defaultvalue="-1" name="day" propertyname="SelectedValue" /> </selectparameters>
The class I use is like any other class (but serializable)
[Serializable] public class Customer { public int CustomerID { get; set; } }
I'm trying to reference a public property from a string. How can this be done in vb.net? I have the text value of "FirstName" stored in strucParam(i).TxtPropertyName.
This is what I'm currently doing:
Dim tmpValue As String Dim ucAppName As UserControl_appName = CType(Parent.FindControl(strucParam(i).ParentFindControl), UserControl_appName) tmpValue = ucAppName.FirstName.Text
How can I use the value in strucParam(i).TxtPropertyName so that I can remove ".FirstName" from my code?
public class InvestorMailing { public string To { get; set; } public IEnumerable<string> Attachments { get; set; } public int AttachmentCount { get; set; } public long AttachmentSize { get; set; } }
i have an IList<InvestorMailing> mailingList. if the attachment size is greater than x, then i need to split my object into chunks. is there an easy linq-y way to do this?
I'm having problem in inserting text from a textbox in which user write or copy some text which may contain special characters ( " , . ) etc. If there is any special character it get conflict with CommandText Syntax and generates error in inserting. I want to insert all these characters. How could i do it?
I'm beginner in AJAX. I was developing an ASP.Net Web-Site (MVS 2008, ASP.Net version 2.0.50727), so on current step I need pop-up windows with server code functionality. I decided to try AJAX. I have downloaded the latest version AjaxControlToolkit.Binary.NET35, added dll to Bin folder, and writed code as: [Code]....
I use ScriptManager coz I can't compile project with ToolkitScriptManager. When I start web site I can't get the expected result, only I get script error message like "Object doesn't support property or method".
trying a sample from the jquery template plugin. Getting an error:
[Code]....
what do I need to run the templating plugin?here are my script includes ( I added the jquery.tmpl.js file as an existing item to the scripts folder of my MVC project )
I have a list <Department> say Company.Departments with object Manager and ManagerId, ManagerName as property of Manager. I would like to fill the dropdownlist with managers as below