Posts

asp.net mvc - How to use Linq objects to validate a view in MVC 2 -

i use linq , typed views in right way. @ moment following: make model verify agianst: public class menu { public int id { get; private set; } public string text { get; private set; } public string action { get; private set; } public string controller { get; private set; } public string parameter { get; private set; } public string langue { get; private set; } public menu(int id, string controller, string action, string parameter, string text) { id = id; controller = controller; action = action; text = text; parameter = parameter; } use linq data database model: public static list<menu> gettablistformenu(string langue) { page_dbentities entity = new page_dbentities(); var tablist = (from ml in entity.wpmenulangue ml.langue == langue m in entity.wpmenu ml.menu == m.id ...

c - How to use getaddrinfo_a to do async resolve with glibc -

an overlooked function requires no external library, has no documentation whatsoever. update (2010-10-11) : linux man-pages have documentation of getaddrinfo_a, can find here: http://www.kernel.org/doc/man-pages/online/pages/man3/getaddrinfo_a.3.html as disclaimer should add i'm quite new c not newbie, there might bugs, or bad coding practices, please correct me (and grammar sucks too). i didn't know until came upon this post adam langley, shall give few code snippets illustrate usage of , clarify things might not clear on first use. benefits of using data readily usable in socket() , listen() , other functions, , if done right won't have worry ipv4/v6 either. start off basics, taken link above (you need link against libanl (-lanl)) : here function prototype: int getaddrinfo_a(int mode, struct gaicb *list[], int ent, struct sigevent *); the mode either gai_wait (which not want) , gai_nowait async lookups the gaicb argument a...

Excel like server side control for ASP.NET -

we have requirement increase functionality of grid using edit on our webapp, , our manager keeps citing excel perfect example data grid :/ still doesn't spreadsheet control doesn't exist out of box, thought i'd bit of searching nonetheless. i've found couple of products on google, wondering if else has feedback around such controls (obviously cheaper or ahem freer better) edit have telerik controls, 'current' requirement is, control can copy , paste (e.g) 3 cells 1 row , paste them on another, row row editing of telerik doesn't cut it. in competition 'excel' based solution, nightmare in winning users around, prefer flexibility structure update: silverlight fast approaching, maybe can use real excel control. devexpress has powerful grid control both web , windows. not free , guess nothing matches excel. once users started using it, wanted every app it. check these videos data grouping one.

math - Algorithm to find a common multiplier to convert decimal numbers to whole numbers -

i have array of numbers potentially have 8 decimal places , need find smallest common number can multiply them whole numbers. need original numbers can multiplied out same scale , processed sealed system deal whole numbers, can retrieve results , divide them common multiplier relative results. currently few checks on numbers , multiply 100 or 1,000,000, processing done *sealed system can quite expensive when dealing large numbers multiplying million sake of isn’t great option. approximation lets sealed algorithm gets 10 times more expensive every time multiply factor of 10. what efficient algorithm, give best possible result, accomplish need , there mathematical name and/or formula i’m need? *the sealed system isn’t sealed. own/maintain source code 100,000 odd lines of proprietary magic , has been thoroughly bug , performance tested, altering deal floats not option many reasons. system creates grid of x y cells, rects x y dropped grid, “proprietary magic” occurs , results spa...

java - Static factory method with generics -

i have class enumconverter<t extends enum<?>> converts strings correct enum constant enum t (i can't use enum.valueof ). construct instances of class in factory method this: public static <t extends enum<?>> enumconverter<t> getinstance(class<t> enumclass) { return new enumconverter<t>(enumclass.getenumconstants()); } this works, want cache enumconverter instances make sure there 1 per enum, i.e. map , , problem how declare map . closest have come this: private static final map<class<?>, enumconverter<? extends enum<?>>> but error if try return value map factory method: type mismatch: cannot convert enumconverter<capture#1-of ? extends enum<?>> enumconverter<t> any ideas? as want store different sub types in map, compiler can't know actual subtype receiving. think have add cast: public static <t extends enum<?>> enumconverter<t> getinstanc...

javascript - Microsoft JScript runtime error: 'RequestCompleted' is undefined -

anyone got ideas? the above error occurs when following code run: sys.webforms.pagerequestmanager.getinstance().add_endrequest(requestcompleted); within block: <script language="javascript" type="text/javascript"> var postbackelement; sys.webforms.pagerequestmanager.getinstance().add_endrequest(requestcompleted); sys.webforms.pagerequestmanager.getinstance().add_initializerequest(initializerequesthandler); function initializerequesthandler(sender, args) { //set postbackelement postbackelement = args.get_postbackelement(); } you need handle requestcompleted event if you're going use it: function requestcompleted(sender, args) { // need here } if don't need handle event, remove line markup: sys.webforms.pagerequestmanager.getinstance().add_endrequest(requestcompleted);

sql server - How to check which locale is a .NET application running under, without having access to its sourcecode? -

context: i'm in charge of running service written in .net. proprietary application. uses sql server database. ran user member of administrators group in local machine. worked alright before added machine domain. so, added machine domain (win 2003) , changed user member of power users group , now, the problem: of sql sentences tries execute "magically" in spanish localization (where , separates floating point numbers instead of .), leading errors. there fewer columns in insert statement values specified in values clause. number of values in values clause must match number of columns specified in insert statement. @ system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolean breakconnection) operating system , regional settings in machine in english. asked provider of application , said: looks have combination of code running under spanish locale, , sql server under english locale. sql expects '15.28' , no...