Search Results

Search found 263 results on 11 pages for 'binder'.

Page 1/11 | 1 2 3 4 5 6 7 8 9 10 11  | Next Page >

  • SHould i buy Thermal binder or spiral binder [closed]

    - by Mirage
    i need to print a lot of dcuments and the problem i come up with is the stapling all the pages. I thought i should buy a binder which can releive me a lot. I am confused whether i should buy thermal binder or spiral binder. Money is not any problem but i want the long term use. How reliable is the thermal binder? I think spiral binder can last very long as its pure mechanical ANy suggesstions

    Read the article

  • Custom Validation Attribute with Custom Model Binder in MVC 2

    - by griegs
    I apologise for the amount of code I have included. I've tried to keep it to a minimum. I'm trying to have a Custom Validator Attribute on my model as well as a Custom Model binder. The Attribute and the Binder work great seperately but if I have both, then the Validation Attribute no longer works. Here is my code snipped for readability. If I leave out the code in global.asax the custom validation fires but not if I have the custom binder enabled. Validation Attribute; public class IsPhoneNumberAttribute : ValidationAttribute { public override bool IsValid(object value) { //do some checking on 'value' here return true; } } Useage of the attribute in my model; [Required(ErrorMessage = "Please provide a contact number")] [IsPhoneNumberAttribute(ErrorMessage = "Not a valid phone number")] public string Phone { get; set; } Custom Model Binder; public class CustomContactUsBinder : DefaultModelBinder { protected override void OnModelUpdated(ControllerContext controllerContext, ModelBindingContext bindingContext) { ContactFormViewModel contactFormViewModel = bindingContext.Model as ContactFormViewModel; if (!String.IsNullOrEmpty(contactFormViewModel.Phone)) if (contactFormViewModel.Phone.Length > 10) bindingContext.ModelState.AddModelError("Phone", "Phone is too long."); } } Global asax; System.Web.Mvc.ModelBinders.Binders[typeof(ContactFormViewModel)] = new CustomContactUsBinder();

    Read the article

  • Dim an Overly Bright Alarm Clock with a Binder Divider

    - by ETC
    Love your alarm clock but hate how eye-searingly bright it is? Slice up a plastic binder divider to dim your alarm clock (or any other aggressively bright monochromatic display). At DIY site Curbly Chris Job shares a simple alarm clock hack. For years he had an alarm clock with a nice dim display. When it broke he went in search of a replacement but failed to find one that wasn’t . His solution came in form of a sliced up binder divider (the clear, usually tinted, plastic tabs you put in between paper in a binder). He sliced to fit the display, spritzed it with a little water to help it cling to the plastic, and pressed it in place. The plastic dims the display enough–as seen in the before/after picture above–that he doesn’t need to cover it up to get a good night’s sleep. Calm Your Alarm Clock’s Display and Sleep Better for 25¢ [Curbly] Latest Features How-To Geek ETC Have You Ever Wondered How Your Operating System Got Its Name? Should You Delete Windows 7 Service Pack Backup Files to Save Space? What Can Super Mario Teach Us About Graphics Technology? Windows 7 Service Pack 1 is Released: But Should You Install It? How To Make Hundreds of Complex Photo Edits in Seconds With Photoshop Actions How to Enable User-Specific Wireless Networks in Windows 7 Dim an Overly Bright Alarm Clock with a Binder Divider Preliminary List of Keyboard Shortcuts for Unity Now Available Bring a Touch of the Wild West to Your Desktop with the Rango Theme for Windows 7 Manage Your Favorite Social Accounts in Chrome and Iron with Seesmic E.T. II – Extinction [Fake Movie Sequel Video] Remastered King’s Quest Games Offer Classic Gaming on Modern Machines

    Read the article

  • How to Use Binder Clips to Fix Broken Keyboard Feet [Geeky Quick Fix]

    - by Asian Angel
    There are few things as frustrating as using a keyboard with a broken foot on it, so the folks at Apartment Therapy came up with a quick and awesome solution. All it takes is a little bit of binder clip magic… You can see the end results in the images above, so browse on over the blog post for the quick how-to instructions and say goodbye to the broken keyboard feet blues! Images courtesy of Apartment Therapy blog. Use Binder Clips to Mend Broken Keyboard Feet [via Reddit] HTG Explains: Is ReadyBoost Worth Using? HTG Explains: What The Windows Event Viewer Is and How You Can Use It HTG Explains: How Windows Uses The Task Scheduler for System Tasks

    Read the article

  • Custom DateTime model binder in Asp.net MVC

    - by Robert Koritnik
    I would like to write my own model binder for DateTime type. First of all I'd like to write a new attribute that I can attach to my model property like: [DateTimeFormat("d.M.yyyy")] public DateTime Birth { get; set,} This is the easy part. But the binder part is a bit more difficult. I would like to add a new model binder for type DateTime. I can either implement IModelBinder interface and write my own BindModel() method inherit from DefaultModelBinder and override BindModel() method My model has a property as seen above (Birth). So when the model tries to bind request data to this property, my model binder's BindModel(controllerContext, bindingContext) gets invoked. Everything ok, but. How do I get property attributes from controller/bindingContext, to parse my date correctly? How can I get to the PropertyDesciptor of property Birth? Edit Because of separation of concerns my model class is defined in an assembly that doesn't (and shouldn't) reference System.Web.MVC assembly. Setting custom binding (similar to Scott Hanselman's example) attributes is a no-go here.

    Read the article

  • Custom model binder for model inner property

    - by Andrej Kaurin
    My model is like this public class MyModel { string ID {get;set;} string Title {get;set;} MyOtherModel Meta {get;set;} } How to define custom model binder for type (MyOtherModel) so when default binder binds MyModel it calls custom model binder for 'Meta' property. I registered it in App start like: ModelBinders.Binders[typeof(MyOtherModel)] = new MyCustomBinder(); but this doesn't work. Any idea or any good article with more infor regarding to model binders?

    Read the article

  • Binding a list belonging to another object in a custom model binder in ASP.NET MVC

    - by Dan
    I realize something like this has been asked, but this may be a little different Below is my Event object: Event : IEvent public int Id public string Title public List<EventContact> Contacts And EventContact: EventContact public int Id public string Name So, an Event has a list of EventContact' objects. Now, Event also implements IEvent - hence the custom model binder. I useIEventinstead of Event, so when the default model binder tries to do its thing, it lets me know it can't create anIEvent'. I have my view with populated with the contact info: <input type="text" name="contact[0].Name" value="DB Value"/> <input type="text" name="contact[1].Name" value="DB Value"/> <input type="text" name="contact[2].Name" value="DB Value"/> <!-- Event fields, etc --> So, in my custom model binder I am able to see all the value - sweet! The only thing is, I'm really not sure how to get all the contact fields and create a list of contacts from them, along with binding all the Event fields. Any and all help is appreciated!

    Read the article

  • asp.net mvc - bootstrapping object via model binder

    - by csetzkorn
    Hi, I have a domain object Thing which can contain several Categories. So I have implemented my HTML helper to create a checkbox group of all possible Categories. I have no problem receiving: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Thing Thing, List<string> Categories) However I am wondering whether I could use a custom Model binder to use just this: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Thing Thing) So basically I am looking for a way to use the model binder to bootstrap the object tree/graph. Any pointers appreciated. Thanks. Christian

    Read the article

  • Should a model binder populate all of the model?

    - by Richard
    Should a model binder populate all of the model, or only the bits that are being posted? For example, I am adding a product in my system and on the form i want the user to select which sites the new product will appear on. Therefore, in my model I want to populate a collection called "AllAvailableSites" to render the checkboxes for the user to choose from. I also need to populate the model with any chosen sites on a post in case the form does not validate, and I need to represent the form showing the initial selections. It would seem that I should let the model binder set the chosen sites on the model, and (once in the controller method) I set the "AllAvailableSites" on the model. Does that sound right? It seems more efficient to set everything in the model binder but someone is suggesting it is not quite right. I am grateful for any advice; I have to say that all the MVC model binding help online seems to cite really simple examples, nothing complicated. Do I really need a GET and a POST version of a method? Can't they just take the same view model? Then I check in my model binder if it is a GET/POST, and populate all the model accordingly.

    Read the article

  • Custom Model binder not firing

    - by mare
    This is my custom model binder. I have my breakpoint set at BindModel but does not get fired with this controller action: public ActionResult Create(TabGroup tabGroup) ... public class BaseContentObjectCommonPropertiesBinder : DefaultModelBinder { public new object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { if (controllerContext == null) { throw new ArgumentNullException("controllerContext"); } if (bindingContext == null) { throw new ArgumentNullException("bindingContext"); } BaseContentObject obj = (BaseContentObject)base.BindModel(controllerContext, bindingContext); obj.Modified = DateTime.Now; obj.Created = DateTime.Now; obj.ModifiedBy = obj.CreatedBy = controllerContext.HttpContext.User.Identity.Name; return obj; } My registration: // tried both of these two lines ModelBinders.Binders[typeof(TabGroup)] = new BaseContentObjectCommonPropertiesBinder(); ModelBinders.Binders.Add(typeof(TabGroup), new BaseContentObjectCommonPropertiesBinder());

    Read the article

  • asp.net mvc custom model binder

    - by mike
    pleas help guys, my custom model binder which has been working perfectly has starting giving me errors details below An item with the same key has already been added. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: An item with the same key has already been added. Source Error: Line 31: { Line 32: string key = bindingContext.ModelName; Line 33: var doc = base.BindModel(controllerContext, bindingContext) as Document; Line 34: Line 35: // DoBasicValidation(bindingContext, doc); Source File: C:\Users\Bich Vu\Documents\Visual Studio 2008\Projects\PitchPortal\PitchPortal.Web\Binders\DocumentModelBinder.cs Line: 33 Stack Trace: [ArgumentException: An item with the same key has already been added.] System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +51 System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) +7462172 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) +270 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, IEqualityComparer1 comparer) +102 System.Web.Mvc.ModelBindingContext.get_PropertyMetadata() +157 System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) +158 System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) +90 System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +50 System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1048 System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +280 PitchPortal.Web.Binders.documentModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) in C:\Users\Bich Vu\Documents\Visual Studio 2008\Projects\PitchPortal\PitchPortal.Web\Binders\DocumentModelBinder.cs:33 System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +257 System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +109 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +314 System.Web.Mvc.Controller.ExecuteCore() +105 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +39 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.<c_DisplayClass8.b_4() +34 System.Web.Mvc.Async.<c_DisplayClass1.b_0() +21 System.Web.Mvc.Async.<c_DisplayClass81.b_7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult1.End() +59 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8677678 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 any ideas guys? Thanks

    Read the article

  • Asp.Net MVC 2 - Iterate Through Form Values In Model Binder

    - by Noob
    I have a list of items in my form which are named like this... <input type="text" id="ListItem1"> <input type="text" id="ListItem2"> <input type="text" id="ListItem3"> I want to create a custom model binder which converts these in to model with this structure... public class MyModel { public IEnumerable<MyModelItem> Items {get; set;} } public class MyModelItem { public int Id { get; set; } public string Value { get; set; } } So each ListItem should be converted to a MyModelItem with id equal to the number at the end of the input id and value set to the value on the input field. In ASP.Net MVC 1.0 I could iterate over the bindingContext.ValueProvider.Keys collection and check for key.StartsWith("ListItem") to find all input items in this format. The new IValueProvider interface in ASP.Net MVC 2 does not have a keys collection and I cannot iterate over that interface. How can I access these values which I only know the prefix for at design time in ASP.Net MVC 2?

    Read the article

  • asp.net mvc custom model binder

    - by mike
    pleas help guys, my custom model binder which has been working perfectly has starting giving me errors details below An item with the same key has already been added. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: An item with the same key has already been added. Source Error: Line 31: { Line 32: string key = bindingContext.ModelName; Line 33: var doc = base.BindModel(controllerContext, bindingContext) as Document; Line 34: Line 35: // DoBasicValidation(bindingContext, doc); Source File: C:\Users\Bich Vu\Documents\Visual Studio 2008\Projects\PitchPortal\PitchPortal.Web\Binders\DocumentModelBinder.cs Line: 33 Stack Trace: [ArgumentException: An item with the same key has already been added.] System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +51 System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) +7462172 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) +270 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, IEqualityComparer1 comparer) +102 System.Web.Mvc.ModelBindingContext.get_PropertyMetadata() +157 System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) +158 System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) +90 System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +50 System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1048 System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +280 PitchPortal.Web.Binders.documentModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) in C:\Users\Bich Vu\Documents\Visual Studio 2008\Projects\PitchPortal\PitchPortal.Web\Binders\DocumentModelBinder.cs:33 System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +257 System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +109 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +314 System.Web.Mvc.Controller.ExecuteCore() +105 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +39 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.<c_DisplayClass8.b_4() +34 System.Web.Mvc.Async.<c_DisplayClass1.b_0() +21 System.Web.Mvc.Async.<c__DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult1.End() +59 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8677678 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 any ideas guys? Thanks

    Read the article

  • MVC Localization of Default Model Binder

    - by Dai Bok
    Hi, I am currently trying to figure out how to localize the error messages generated by MVC. Let me use the default model binder as an example, so I can explain the problem. Assuming I have a form, where a user enters thier age. The user then enters "ten" in to the form, but instead of getting the expected error of "Age must be beween 18 and 25." the message "The value 'ten' is not valid for Age." is displayed. The entity's age property is defined below: [Range(18, 25, ErrorMessageResourceType = typeof (Errors), ErrorMessageResourceName = "Age", ErrorMessage = "Range_ErrorMessage")] public int Age { get; set; } After some digging, I notice that this error text comes from the System.Web.Mvc.Resources.DefaultModelBinder_ValueInvalid in the MvcResources.resx file. Now, how can create localized versions of this file? As A solution, for example, should I download MVC source and add MvcResources.en_GB.resx, MvcResources.fr_FR.resx, MvcResources.es_ES.resx and MvcResources.de_DE.resx, and then compile my own version of MVC.dll? But I don't like this idea. Any one else know a better way?

    Read the article

  • Reading only one row from table in model binder

    - by user281180
    I am filling a table dynamically. I can see the table filled with 3 rows, but in my model binder I can read only one value. How can I solve this problem? My code is as follows: function AddTableRow(jQtable, value, text){ var count = 0; jQtable.each(function() { var $table = $(this); var tds = '<tr>'; tds += '<td>' + '<input type="text" value = ' + text + ' disabled ="disabled" style="width:auto"/>' + '<input type="hidden" name="projectList[' + count + '].ID" value = ' + value + ' /></td>' + '<td><input type="button" value="Remove"/></td>'; tds += '</tr>'; if ($('tbody', this).length > 0) { $('tbody', this).append(tds); } else { $(this).append(tds); } count++;}); } function ReadSelectedProject() { $("#Selected option").each(function() { AddTableRow($('#projectTable'), $(this).val(), $(this).text()); }); }

    Read the article

  • CSS selector not resolved when using UI Binder

    - by Zhaidarbek
    Basically, I am building a horizontal navigation bar. I have following markup: <ui:style src="../common.css" type="client.resources.HomeResources.Style"> @external gwt-Anchor; .gwt-Anchor { text-decoration: none; } </ui:style> <g:HTMLPanel styleName="navbar"> <ul> <li><g:Anchor ></g:Anchor> |</li> <li><g:Anchor ></g:Anchor> |</li> <li><g:Anchor ></g:Anchor> |</li> <li><g:Anchor ></g:Anchor> |</li> <li><g:Anchor ></g:Anchor> |</li> <li><g:Anchor ></g:Anchor> |</li> <li><g:Anchor ></g:Anchor></li> </ul> common.css has following rules: ul { margin: 0; padding: 0; text-align: left; font-weight: bold; line-height: 25px; } ul li { display: inline; text-align: right; } ul li a { color: #0077C0; font-size: 12px; margin-right: 15px; padding: 4px 0 4px 5px; text-decoration: none; } ul li a:HOVER { color: #F0721C; } When using rules as defined above, everything works perfect. The problem is that I have ul elements in other parts of page, so I've added div.navbar before each rule like this: div.navbar ul{} div.navbar ul li{} etc... But those rules are not applied to ul elements inside UI Binder template. What's wrong with my code? Here is the generated HTML (normally on one line): <div class="navbar"><ul> <li><a class="gwt-Anchor">Item 1</a> |</li> <li><a class="gwt-Anchor">Item 2</a> |</li> <li><a class="gwt-Anchor">Item 3</a></li> </ul></div> RESOLVED styleName="navbar" must be styleName="{style.navbar}"

    Read the article

  • ASP.NET MVC: null reference exception using HtmlHelper.TextBox and custom model binder

    - by mr.nicksta
    I have written a class which implements IModelBinder (see below). This class handles a form which has 3 inputs each representing parts of a date value (day, month, year). I have also written a corresponding HtmlHelper extension method to print out three fields on the form. When the day, month, year inputs are given values which can be parsed, but a seperate value fails validation, all is fine - the fields are repopulated and the page served to the user as expected. however when an invalid values are supplied and a DateTime cannot be parsed, i return an arbitrary DateTime so that the fields will be repopulated when returned to the user. I read up on similar problems people have had and they all seemed to be due to lack of calling SetModelValue(). I wasn't doing this, but even after adding the problem has not been resolved. public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { string modelName = bindingContext.ModelName; string monthKey = modelName + ".Month"; string dayKey = modelName + ".Day"; string yearKey = modelName + ".Year"; //get values submitted on form string year = bindingContext.ValueProvider[yearKey].AttemptedValue; string month = bindingContext.ValueProvider[monthKey].AttemptedValue; string day = bindingContext.ValueProvider[dayKey].AttemptedValue; DateTime parsedDate; if (DateTime.TryParse(string.Format(DateFormat, year, month, day), out parsedDate)) return parsedDate; //could not parse date time report error, return current date bindingContext.ModelState.AddModelError(yearKey, ValidationErrorMessages.DateInvalid); //added this after reading similar problems, does not fix! bindingContext.ModelState.SetModelValue(modelName, bindingContext.ValueProvider[modelName]); return DateTime.Today; } the null reference exception is thrown when i attempt to create a textbox for the Year property of the date, but strangely not for Day or Month! Can anyone offer an explanation as to why this is? Thanks :-)

    Read the article

  • ASP.NET MVC2 - Resolve Parameter Attribute in Model Binder

    - by Nathan Taylor
    Given an action like: public ActionResult DoStuff([CustomAttribute("foo")]string value) { // ... } Is there any way to resolve the instance of value's CustomAttribute within a ModelBinder? I was looking at the MVC sources and chances are I'm just doing it wrong, but when I tried to replicate their code which retrieves the BindAttribute for a complex model, calling GetAttributes() did not return the attribute I am looking for. DefaultModelBinder GetTypeDescriptor(controllerContext, bindingContext).GetAttributes();

    Read the article

  • ASP.NET Model Binder and base type

    - by user137348
    My model inherits from an interface: public interface IGrid { ISearchExpression Search { get; set; } . . } public interface ISearchExpression { IRelationPredicateBucket Get(); } The model: public class Project : IGrid { public ISearchExpression Search { get; set; } public Project() { this.Search = new ProjectSearch(); } } The ProjectSearch: public class ProjectSearch: ISearchExpression { public string Name { get; set; } public string Number { get; set; } public IRelationPredicateBucket Get() {...} } And the strong typed partialview in the main view: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ProjectSearch>" %> <%= Html.TextBoxFor(x=>x.Name)%> <%= Html.TextBoxFor(x => x.Number)%> .... When I submit the form, the Search property don't get bound properly. Everything is empty.The action takes an argument of ProjectSearch type. Why the Search don't get bound as supposed ?

    Read the article

  • Binder and variadic template ends up in a segmentation fault

    - by phlipsy
    I wrote the following program #include <iostream> template<typename C, typename Res, typename... Args> class bind_class_t { private: Res (C::*f)(Args...); C *c; public: bind_class_t(Res (C::*f)(Args...), C* c) : f(f), c(c) { } Res operator() (Args... args) { return (c->*f)(args...); } }; template<typename C, typename Res, typename... Args> bind_class_t<C, Res, Args...> bind_class(Res (C::*f)(Args...), C* c) { return bind_class<C, Res, Args...>(f, c); } class test { public: int add(int x, int y) { return x + y; } }; int main() { test t; // bind_class_t<test, int, int, int> b(&test::add, &t); bind_class_t<test, int, int, int> b = bind_class(&test::add, &t); std::cout << b(1, 2) << std::endl; return 0; } compiled it with gcc 4.3.3 and got a segmentation fault. After spending some time with gdb and this program it seems to me that the addresses of the function and the class are mixed up and a call of the data address of the class isn't allowed. Moreover if I use the commented line instead everything works fine. Can anyone else reproduce this behavior and/or explain me what's going wrong here?

    Read the article

  • MVC Custom Model Binder Binding Multiple Values

    - by BMD86
    Hello everyone, I have a scenario in which I have multiple sources to bind to my model. For one, I have a view tied to a strongly-typed model, but this scenario also entails posting data to this view from a 3rd party site. Essentially, what I believe I am after in the custom model binding is to investigate the form values in the Request object within HTTPContext to see if I have a field such as "postedFirstName". If so, I want to bind that value instead of the textbox "FirstName" in my view. I've done a good bit of searching but have not find anything that exactly addresses such a scenario. This link was close, I thought, but not quite: http://stackoverflow.com/questions/970335/asp-net-mvc-mixing-custom-and-default-model-binding Any input is greatly appreciated!

    Read the article

  • Model availability inside ActionFilter

    - by Sayed Ibrahim Hashimi
    I have created a new ActionFilter for an ASP.NET MVC application that I'm creating. I have an action which accepts an Http Post and the argument of the action method accepts an object, for which I have created and registered a custom model binder. I noticed that inside the IActionFilter.OnActionExecuting the value for filterContext.Controller.ViewData.Model is always null despite the fact that it looks like the model binder is always invoked before the action filter OnActionExecuting method. In contrast to this inside the IActionFilter.OnActionExecuted method of the same action filter the value for filterContext.Controller.ViewData.Model is not null. Do you guys know if this is by design or a bug? If by design are their any links which describe why this is? Thanks.

    Read the article

  • System.Dynamic bug?

    - by ControlFlow
    While I playing with the C# 4.0 dynamic, I found strange things happening with the code like this: using System.Dynamic; sealed class Foo : DynamicObject { public override bool TryInvoke( InvokeBinder binder, object[] args, out object result) { result = new object(); return true; } static void Main() { dynamic foo = new Foo(); var t1 = foo(0); var t2 = foo(0); var t3 = foo(0); var t4 = foo(0); var t5 = foo(0); } } Ok, it works but... take a look at IntelliTrace window: So every invokation (and other operations too on dynamic object) causes throwing and catching strange exceptions twice! I understand, that sometimes exceptions mechanism may be used for optimizations, for example first call to dynamic may be performed to some stub delegate, that simply throws exception - this may be like a signal to dynamic binder to resolve an correct member and re-point delegate. Next call to the same delegate will be performed without any checks. But... behavior of the code above looks very strange. Maybe throwing and catching exceptions twice per any operation on DynamicObject - is a bug?

    Read the article

  • Is it okay to mix session data with form and querystring values in a custom model binder?

    - by Byron Sommardahl
    Working on a custom model binder in ASP.NET MVC 2. Most of the time I am binding data from typical form or querystring data. There are times that I end up letting the model binder bind part of an object and get the rest out of session at the controller action level. Does it make better sense to bind the entire object from the model binder (e.g. querystring, form, and session)?

    Read the article

1 2 3 4 5 6 7 8 9 10 11  | Next Page >