I have got an enumeration in C# ie something like Category.cs. In a dropdownlist we are binding values. So if the user selects some specific value in dropdown it will hide one div. So i want to get the enumeration value in javascript ie want to compare the enumeration value with one selected value in javascript.
I am having a nightmare with getting a Dropdownlist control to work correctly in my MVC application. I am trying to get a set of values out of an enumeration into SelectListItem which I then present to the DropDownList control as its source. The issue is that I can get the thing to render but the selected value is never set and to top it off when the form is posted the value passed across is 0 instead of the actual value. In the View (Razor Code):
HTML4Strict Code: @Html.DropDownList("UserRole", new SelectList(Enum.GetValues(typeof(enumUserRoleUserManagement)), user.UserRole), new { @onchange = "submitForm(" + i + ")" }) in the Controller: Csharp Code: ViewData["RL"] = new SelectList(userActionsModel.GenerateCombo().AsEnumerable(), "Value", "Text"); And Finally in the model: Csharp Code: public IEnumerable<SelectListItem> GenerateCombo() { var enumerationValues = Enum.GetValues(typeof(enumUserRoleUserManagement)); var enumerationNames = Enum.GetNames(typeof(enumUserRoleUserManagement)); List<SelectListItem> list = new List<SelectListItem>(); foreach (var value in Enum.GetValues(typeof(enumUserRoleUserManagement))) { SelectListItem selectList = new SelectListItem { Text = value.ToString(), Value = value.ToString() }; list.Add(selectList); } //SelectList selectList = new SelectList(list); return list;}
I have burned soooo much time on this, I will be indebted to anyone that provides a solution.
I have a simple ASP.Net page, and I am enumerating through the controls doing things to the controls via reflection (localising the page - but that is whole other can of managerial dictat type worms). So...I have a test page thus:
Now, if I just run this, it barfs with an object null exception. And if I step through the code, putting a breakpoint on the control.ID line, then indeed the ID is null. However, if I then expand the control object, the ID fills itself out and all is well.
It looks like the ID is only getting completed at the last moment - how can I ensure that I can get the ID without getting null? The same thing happens if I don't use the master page.
I'm storing a dataset in an ASP.Net WebApplication-Cache. Every user in this intranet-app uses the same instance. On insert/update/delete-actions the database will be updated and the dataset is modified accordingly.
But rarely I get an exception that indicates that I've missed something. I assume that it must have something to do with thread safety.
Collection was modified; enumeration operation might not execute
In lines where i access a DataTable in the Dataset, for example:
Dim view As New DataView(dsERP.ERP_Charge, filter, sort, _ Data.DataViewRowState.CurrentRows)
It was apparently changed by another thread while the view enumerates the datatable.
What is the best way to make this thread safe?
Edit: as you've mentioned i need to lock the objects on add/edit/delete operations. MSDN* says that a DataSet is thread-safe for multiple users. What does this mean, are the DataTables in the Dataset also thread-safe? And how to lock a single datatable on write-operations and not the whole dataset?
*ADO.NET - Multithreaded Programming ADO.NET is optimized for performance, throughput, and scalability. As a result, the ADO.NET objects do not lock resources and must only be used on a single thread. The one exception is the DataSet, which is thread-safe for multiple readers. However, you need lock the DataSet during writes.
This is the property that returns the dataset:
Public ReadOnly Property dsERP() As ERPModel.dsERP Get If Cache("DS_ERP") Is Nothing Then Cache("DS_ERP") = New ERPModel.dsERP FillDataSet() End If Return DirectCast(Cache("DS_ERP"), ERPModel.dsERP) End Get End Property
i've modified the insert/update and delete operations in the following way(dsRma is a dataset):
Dim success As Boolean SyncLock dsRMA.RMA success = insert() End SyncLock
First, does it work now if another thread tries to enumerate the RMA-Table? Second, is it sufficient to lock the datarow that gets updated instead of locking the whole datatable(see below)?
Dim thisRMA As ERPModel.dsRMA.RMARow = dsRMA.RMA.FindByIdRMA(Me.IdRma) Dim success As Boolean SyncLock thisRMA success = update(thisRMA) End SyncLock
In the span's onclick handler i wrote "javascript: alert(getAppSetting('ftpuser'));" for testing, and built some alerts into the function. The first alert returns [object]. That's nice, i thought. The second alert returned 0. That's strange, because the web.config has exactly 1 of this node. So i guess that the function doesn't actually load the correct document. Has anyone done something similar ? When i don't suppy a full path, doesn't javascript assume that it should look for the file in the virtual directory of the current web application where the web.config is ?
Basically I want to display a popup box only at a specific time in asp.net application. so i'm using the following
[code]....
but this code is not working. the alert box is not popping up. is this a correct method to pass values to the script?. or what else to be done to meet the requirement?.
I came across old web application which has the code to read the parameters from the URL of the site. The code is full of string processing. http://hostname.domain[port number]/application name?arg1=value1...&argN=valueN onsidering that URL parameters are always encoded it is litter difficult to rely on string processing. Also not sure if one can rely 100% on the URLEncode/Decode functions of the JavaScript.
function getURLParameters(){ if (location.search != "") var x = location.search.substr(1).split(";") for (var i=0; i<x.length; i++) var y = x[i].split("=");
I would like to multiply the values from two text boxes (txtBox1 should contain an Integer value, txtBox2 should contain a Float value) and place the result in a third text box. My code is below, but it doesn't work. The javascript function is called, otherwise it fails.
I'm using jQueryGrid and an Action method to populate search results based on some filter criteria, how to pass this form collection values to Action method from Javascript function.
I 'm using visual studio 2007 and I have come up with an error in my web config that I have never come up with before. I have set customError mode "off" in my web config and I'm getting an error code of The 'mode' attribute is invalid ' The value 'off' is invalid according to it's data type 'NM Token' - the enumeration constraint failed what an 'NM token' is and what I can do to fix this problem? My page works perfectly when I'm working on it locally, but when I move it to the web server I get an error and it tells me to set the custom mode errors in the web config to 'off' This is the error I'm getting:
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
I need to query for a session variable called 'steps' every 10 seconds from my Webform in ASP.Net using javascript. This session variable holds an integer value.
I have a parent page that launches a telerik radwindow and passes it an argument.
Once the radwindow is done processeing the value, I need it to return it to the parent page, and I would like the parent page to have access to this value in my code behind page.
I have tried to pass the value to a hidden field on my page and then trigger a page refresh and my code behind watches to see if the value is working.
I can't seem to get this to work. I get the return value in the parent javascript, but i can't get it from my hidden field from the code behind.
I have a table with 5 rows and 2 columns. Each cell contains a text box. I want to show error if one of the text boxes in each column is empty. I want both text boxes in a row shld be filled or both shld empty. How can i do this via Asp.net validation controls? I want to extend CompareValidator so that it will validate only if the controlToValidate and controlToCompare both have some text in it or both are empty.