Search Results

Search found 25779 results on 1032 pages for 'custom model binder'.

Page 16/1032 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Dynamically add event to custom control (Confirm Message Box)

    - by Nyein Nyein Chan Chan
    I have created a custom cofirm message box control and I created an event like this- [Category("Action")] [Description("Raised when the user clicks the button(ok)")] public event EventHandler Submit; protected virtual void OnSubmit(EventArgs e) { if (Submit != null) Submit(this, e); } The Event OnSubmit occurs when user click the OK button on the Confrim Box. void IPostBackEventHandler.RaisePostBackEvent(string eventArgument) { OnSubmit(e); } Now I am adding this OnSubmit Event Dynamically like this- In aspx- <my:ConfirmMessageBox ID="cfmTest" runat="server" ></my:ConfirmMessageBox> <asp:Button ID="btnCallMsg" runat="server" onclick="btnCallMsg_Click" /> <asp:TextBox ID="txtResult" runat="server" ></asp:TextBox> In cs- protected void btnCallMsg_Click(object sender, EventArgs e) { cfmTest.Submit += cfmTest_Submit;//Dynamically Add Event cfmTest.ShowConfirm("Are you sure to Save Data?"); //Show Confirm Message using Custom Control Message Box } protected void cfmTest_Submit(object sender, EventArgs e) { txtResult.Text = "User Confirmed";//I set the text to "User Confrimed" but it's not displayed txtResult.Focus();//I focus the textbox but I got Error } The Error I got is- System.InvalidOperationException was unhandled by user code Message="SetFocus can only be called before and during PreRender." Source="System.Web" So, when I dynamically add and fire custom control's event, there is an error in Web Control. If I add event in aspx file like this, <my:ConfirmMessageBox ID="cfmTest" runat="server" OnSubmit="cfmTest_Submit"></my:ConfirmMessageBox> There is no error and work fine. Can anybody help me to add event dynamically to custom control? Thanks.

    Read the article

  • Read attributes of MSBuild custom tasks via events in the Logger

    - by gt
    I am trying to write a MSBuild logger module which logs information when receiving TaskStarted events about the Task and its parameters. The build is run with the command: MSBuild.exe /logger:MyLogger.dll build.xml Within the build.xml is a sequence of tasks, most of which have been custom written to compile a (C++ or C#) solution, and are accessed with the following custom Task: <DoCompile Desc="Building MyProject 1" Param1="$(Param1Value)" /> <DoCompile Desc="Building MyProject 2" Param1="$(Param1Value)" /> <!-- etc --> The custom build task DoCompile is defined as: public class DoCompile : Microsoft.Build.Utilities.Task { [Required] public string Description { set { _description = value; } } // ... more code here ... } Whilst the build is running, as each task starts, the logger module receives IEventSource.TaskStarted events, subscribed to as follows: public class MyLogger : Microsoft.Build.Utilities.Logger { public override void Initialize(Microsoft.Build.Framework.IEventSource eventSource) { eventSource.TaskStarted += taskStarted; } private void taskStarted(object sender, Microsoft.Build.Framework.TaskStartedEventArgs e) { // write e.TaskName, attributes and e.Timestamp to log file } } The problem I have is that in the taskStarted() method above, I want to be able to access the attributes of the task for which the event was fired. I only have access to the logger code and cannot change either the build.xml or the custom build tasks. Can anyone suggest a way I can do this?

    Read the article

  • C# custom control to get internal text as string

    - by Ed Woodcock
    ok, I'm working on a custom control that can contain some javascript, and read this out of the page into a string field. This is a workaround for dynamic javascript inside an updatepanel. At the moment, I've got it working, but if I try to put a server tag inside the block: <custom:control ID="Custom" runat="server"> <%= ControlName.ClientID %> </custom:control> The compiler does not like it. I know these are generated at runtime, and so might not be compatible with what I'm doing, but does anyone have any idea how I can get that working? EDIT Error message is: Code blocks are not supported in this context EDIT 2 The control: [DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), ControlValueProperty("Text"), DefaultProperty("Text"), ParseChildren(true, "Text"), AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class CustomControl : Control, ITextControl { [DefaultValue(""), Bindable(true), Localizable(true)] public string Text { get { return (string)(ViewState["Text"] ?? string.Empty); } set { ViewState["Text"] = value; } } }

    Read the article

  • Avoiding anemic domain model - a real example

    - by cbp
    I am trying to understand Anemic Domain Models and why they are supposedly an anti-pattern. Here is a real world example. I have an Employee class, which has a ton of properties - name, gender, username, etc public class Employee { public string Name { get; set; } public string Gender { get; set; } public string Username { get; set; } // Etc.. mostly getters and setters } Next we have a system that involves rotating incoming phone calls and website enquiries (known as 'leads') evenly amongst sales staff. This system is quite complex as it involves round-robining enquiries, checking for holidays, employee preferences etc. So this system is currently seperated out into a service: EmployeeLeadRotationService. public class EmployeeLeadRotationService : IEmployeeLeadRotationService { private IEmployeeRepository _employeeRepository; // ...plus lots of other injected repositories and services public void SelectEmployee(ILead lead) { // Etc. lots of complex logic } } Then on the backside of our website enquiry form we have code like this: public void SubmitForm() { var lead = CreateLeadFromFormInput(); var selectedEmployee = Kernel.Get<IEmployeeLeadRotationService>() .SelectEmployee(lead); Response.Write(employee.Name + " will handle your enquiry. Thanks."); } I don't really encounter many problems with this approach, but supposedly this is something that I should run screaming from because it is an Anemic Domain Model. But for me its not clear where the logic in the lead rotation service should go. Should it go in the lead? Should it go in the employee? What about all the injected repositories etc that the rotation service requires - how would they be injected into the employee, given that most of the time when dealing with an employee we don't need any of these repositories?

    Read the article

  • Custom Model Validator for MVC

    - by scottrakes
    I am trying to add a custom model validation at the property level but need to pass in two values. Below is my class definition and validation implementation. When it runs, the "value" in the IsValid method is always null. I can get this working at the class level but the property level is causing me issues. What am I missing? Event Class: public class Event { public int? EventID {get;set;} [ValidPURL("EventID", "PURLValue")] public string PURLValue { get; set; } ... } Validation Class [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)] public sealed class ValidPURL : ValidationAttribute { private const string _defaultErrorMessage = "Web address already exist."; private readonly object _typeId = new object(); public ValidPURL(int eventID, string purlValue) : base(_defaultErrorMessage) { EventID = eventID; PURLValue = purlValue; } public int EventID { get; private set; } public string PURLValue { get; private set; } public override object TypeId { get { return _typeId; } } public override string FormatErrorMessage(string name) { return String.Format(CultureInfo.CurrentUICulture, ErrorMessageString, EventID, PURLValue); } public override bool IsValid(object value) { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value); object eventIDValue = properties.Find(EventID, true /* ignoreCase */).GetValue(value); object purlValue = properties.Find(PURLValue, true /* ignoreCase */).GetValue(value); [Some Validation Logic against the database] return true; } } Thank for the help!

    Read the article

  • Strange results about C++11 memory model (Relaxed ordering)

    - by Dancing_bunny
    I was testing the example in the memory model of the Anthony Williams's book "C++ Concurrency" #include<atomic> #include<thread> #include<cassert> std::atomic_bool x,y; std::atomic_int z; void write_x_then_y() { x.store(true, std::memory_order_relaxed); y.store(true, std::memory_order_relaxed); } void read_y_then_x() { while(!y.load(std::memory_order_relaxed)); if(x.load(std::memory_order_relaxed)) { ++z; } } int main() { x = false; y = false; z = 0; std::thread a(write_x_then_y); std::thread b(read_y_then_x); a.join(); b.join(); assert(z.load()!=0); } According to the explanation, relaxed operations on difference variables (here x and y) can be freely reordered. However, I repeated running the problem for more than several days. I never hit the situation that the assertion (assert(z.load()!=0);) fires. I just use the default optimization and compile the code using g++ -std=c++11 -lpthread dataRaceAtomic.cpp Does anyone actually try it and hit the assertion? Could anyone give me an explanation about my test results? BTW, I also tried the version without using the atomic type, I got the same result. Currently, both programs are running healthily. Thanks.

    Read the article

  • cakephp - form for belongsTo Model

    - by user1511579
    I createt the following model to link 2 relational tables: class Ficha extends AppModel { //public $useTable = 'ficha_seg'; var $primaryKey = 'id_ficha'; var $name = 'Ficha'; var $belongsTo = array( 'Perigo' => array( 'className' => 'Perigo', 'foreignKey' => false, 'conditions' => 'Perigo.id_fichas = Ficha.id_ficha' ) ); } Now, i have a form that requires data from the class Ficha, and then is redirected to another ctp page where i will input the data for the table "Perigos". However, since i'm still a newbie in cakephp i'm having difficult building that second form to insert the data on the table "Perigos". Here goes the code i built at the moment related to the second form: FichasController.php (the method where is it supposed to save the data on the table "Perigos": public function preencher_ficha(){ if ($this->request->is('ficha')) { $this->Ficha->create(); if ($this->Ficha->Perigo->save($this->request->data)) { $last_id=$this->Ficha->getLastInsertID(); $this->Session->setFlash('Your post has been updated '.$last_id.'.'); //$this->redirect(array('action' => 'preencher_ficha')); } else { $this->Session->setFlash('Unable to qualquer coisa your post.'); } } } The preencher_ficha.ctp file with the form: echo $this->Form->create('Ficha->Perigo', array('action' => 'index')); echo $this->Form->input('class_subst', array('label' => 'Classificação:')); echo $this->Form->input('simbolos_perigo', array('label' => 'Símbolos:')); echo $this->Form->input('frases_r', array('label' => 'Frases:')); echo $this->Form->end('Finalizar Ficha'); Here i guess the create part is wrong, but i think i have errors too in the controller part.

    Read the article

  • Good Silverlight Custom ItemsControl Tutorial

    - by Steve Brouillard
    I'm afraid my Google-Foo is failing me again today. I'm trying to find a good tutorial on creating custom ItemsControls in Silverlight (though I imgaine a WPF version might work as well). I'm trying to create a custom ItemsControl that will be something of a virtualized ListBox. What I'm trying to accomplish isn't really similar enough to the current ListBox control to justify trying to modify the existing control, so I figure a custom one is in order here. I have a vague concept of how to accomplish it, but there are definite holes in my understanding. Thanks in advance

    Read the article

  • Vim: Custom Folding function done, custom highlighting required

    - by sixtyfootersdude
    I have defined a function in vim to properly indent folds. Ie so they look like this: Unfolded this is text also text indented text indented text not indented text folded with default function this is text also text +-- 2 lines: indented text ---------------------------- not indented text folded with my new function this is text also text ++- 2 lines: indented text ---------------------------- not indented text The only problem is the the highlighting is still like this: folded with my new function (highlighting shown with tag) this is text also text <hi> ++- 2 lines: indented text ----------------------------</hi> not indented text I would like the highlighting to start at the ++ and not at the beginning of the line. I have looked in the vim manual but could not find anything like that. One so-so solution I found was to make the background black. highlight Folded ctermbg=black ctermfg=white cterm=bold But this make folds less visible. I have tried several variations of: syn keyword Folded lines syn region Folded ... But I don't think that this is the way that folds are selected. Can anyone offer a suggestion? By the way this is my function to indent the folds: set foldmethod=indent function! MyFoldText() let lines = 1 + v:foldend - v:foldstart let ind = indent(v:foldstart) let spaces = '' let i = 0 while i < ind let i = i+1 let spaces = spaces . ' ' endwhile let linestxt = 'lines' if lines == 1 linestxt = 'line' endif return spaces . '+' . v:folddashes . ' '. lines . ' ' . linestxt . ': ' . getline(v:foldstaendfunction endfunction au BufWinEnter,BufRead,BufNewFile * set foldtext=MyFoldText() By the way thanks to njd for helping me get this function setup.

    Read the article

  • Disabling Button with custom Content in Silverlight?

    - by andrej351
    Hi there, What is the easiest way to create a Silverlight Button with custom Content which knows how to 'look' disabled? I.e. if you set IsEnabled="False" it will look greyed out. The custom Content will be dead simple, text and an image. I have done this before in a WPF application quite easily by setting the Content to a StackPanel containing a TextBlock and an Image. I then implemented a Style Trigger on the Image to change it to a greyed out version when it wasn't enabled. The text changed colour by itself. As far as I can tell the custom Content disappears altogether when the button is disabled in Silverlight. Any help is appreciated. Cheers, Andrej.

    Read the article

  • Quick way to create JSF custom component

    - by michael lucas
    I know of two ways of creating custom JSF components: 1. Native JSF way: creating JSF component class, tag, etc. 2. Facelets way: defining component in a xhtml file and then creating appropriate decrption in facelets taglib. Currently I work on a project in which introducing facelets is unfortunately out of the question. On the other hand, creating custom components the standard JSF way seems like a pain in the ass. Is there maybe a third party library that allows creating custom components in the way similar to facelets but doesn't entail the need of using non-standard renderer?

    Read the article

  • Android Custom View to Activity communication

    - by Blumer
    I have a custom control/view that observes the direction of a gesture within its bounds. I would like to send a different message back to the Activity hosting the View depending on the direction of the gesture. I'm having a hard time determine what the right way to do this is. I would think I could raise a custom event in the control and then stick a listener on the control in the activity, but I cannot find any information on custom events in Android. Any help would be appreciated. Thanks.

    Read the article

  • How to configure custom error page in Plesk 9.3 for non existing folder?

    - by Junior Mayhé
    I'm trying to configure Plesk in order to show website visitors a custom error html. The current hosted site is an ASP.NET site. This site shows its custom errors on error403.aspx and error404.aspx files. Now to comply with plesk, I've created error_docs with required files like forbidden.html, etc... When user try to navigate http://mysite.com/a_missing_page.aspx, the visitor is redirected to error404.aspx correctly. But when user try to navigate to a non existent directory http://mysite.com/a_missing_folder/ the site takes me to IIS 404 regular page. Plesk has Custom error documents activated on Web hosting settings. ASP.NET Error pages defined in web.config are showing fine. But it seems plesk wont show its custom html error documents. The bottom line here is about setting up a custom error page to a directory. Is it possible to do this using Plesk or do I have to change it manually on IIS?

    Read the article

  • Ruby on Rails - nested attributes: How do I access the parent model from child model

    - by TMaYaD
    I have a couple of models like so class Bill < ActiveRecord::Base has_many :bill_items belongs_to :store accepts_nested_attributes_for :bill_items end class BillItem <ActiveRecord::Base belongs_to :product belongs_to :bill validate :has_enough_stock def has_enough_stock stock_available = Inventory.product_is(self.product).store_is(self.bill.store).one.quantity errors.add(:quantity, "only #{stock_available} is available") if stock_available < self.quantity end end The above validation so obviously doesn't work because when I'm reading the bill_items from nested attributes inside the bill form, the attributes bill_item.bill_id or bill_item.bill are not available before being saved. So how do I go about doing something like that?

    Read the article

  • CMS for custom application

    - by RH
    We are building a custom application using LAMP with P being PHP. We also need to have CMS to manage various aspects of the site. The two options for the CMS are Build a complete custom CMS from scratch Extend an existing open source CMS to fit our needs. This way we can use some of the features out of the box and others we will build ourselves. I would like to get your feedback on the following What are your experiences with option number 2? Which CMS would you recommend that we can further customize and extend for our use? What are the best ways to integrate a custom application with other external CMS?

    Read the article

  • Custom Attributes on Class Members

    - by ccook
    I am using a Custom Attribute to define how a class's members are mapped to properties for posting as a form post (Payment Gateway). I have the custom attribute working just fine, and am able to get the attribute by "name", but would like to get the attribute by the member itself. For example: getFieldName("name"); vs getFieldName(obj.Name); The plan is to write a method to serialize the class with members into a postable string. Here's the test code I have at this point, where ret is a string and PropertyMapping is the custom attribute: foreach (MemberInfo i in (typeof(CustomClass)).GetMember("Name")) { foreach (object at in i.GetCustomAttributes(true)) { PropertyMapping map = at as PropertyMapping; if (map != null) { ret += map.FieldName; } } } Thanks in advance!

    Read the article

  • How to read custom file properties in c#

    - by Randy Gamage
    I'm looking for a way to read document properties in C#. I've heard about dsofile.dll, but it seems like an old COM wrapper, and was wondering if there is something more modern for the .NET framework/C#. What I'm actually reading is not an office document file, but a Solidworks .SLDDRW file, that has Custom properties. You can view and change these in Windows Explorer by right-clicking on the file, and going to the Properties window, Custom tab. Anyone know how to read these custom properties in C# / .NET 3.5? Thanks!

    Read the article

  • Custom HTTP Request headers in HTML

    - by matsko
    Does anyone know if its possible to send out custom http REQUEST headers in HTML without having to use javascript (no xhr wrapper). Would it be possible to define them as meta tags within the head? Or may they be defined in the form somewhere? <meta http-equip="x-something-custom" name="custom value" /> this works, however, this is a RESPONSE header. What I need to set a REQUEST header. I'm not looking for setting hidden fields in forms, but actual raw http header manipulation with html tags. Is this possible?

    Read the article

  • Wordpress custom post_type templates

    - by roman
    We are currently working on a Wordpress page that reuses data from another Application. To keep things clean, but still use most wordpress features, we decided to use custom post_type settings (register_post_type) for this data. Now the Problem is, that while accessing these Posts is no problem, the Permalink's to them fail with 404's. We currently work around this issue by adding an action to the "template_redirect" hook that essentially performs a query_posts for the name and our custom types. If query_posts found something we load our custom post templates with locate_template. Although this is working, it does not look like a clean solution - can anyone here propose a better way to tackle our problems?

    Read the article

  • Custom Django tag & jQuery

    - by pocoa
    I'm new to Django. Today I created some Django custom tags which is not that hard. But now I wonder what is the best way to include some jQuery or some Javascript code packed into my custom tag definition. What is the regular way to include a custom library into my code? For example: {% faceboxify item %} So assume that it'll create a specific HTML output for Facebox plugin. I just want to learn some elegant way to import this plugin into my code. I want the above definition to be enough for all functionality. Is there any way to do it? I couldn't find any example. Maybe I'm missing something.. Thank you.

    Read the article

  • How do I call the methods in a model via controller? Zend Framework

    - by Joel
    Hi guys, I've been searching for tutorials to better understand this, but I'm having no luck. Please forgive the lengthy explination, but I want make sure I explain myself well. First, I'm quite new to the MVC structure, though I have been doing tutorials and learning as best I can. I have been moving over a live site into the Zend Framework model. So far, I have all the views within views/scripts/index/example.phtml. So therefore I'm using one IndexController and I have the code in each Action method for each page: IE public function exampleAction() Because I didn't know how to interact with a model, I put all the methods at the bottom of the controller (a fat controller). So basically, I had a working site by using a View and Controller and no model. ... Now I'm trying to learn how to incorporate the Model. So I created a View at: view/scripts/calendar/index.phtml I created a new Controller at: controller/CalendarControllers.php and a new model at: model/Calendar.php The problem is I think I'm not correctly communication with the model (I'm still new to OOP). Can you look over my controller and model and tell me if you see a problem. I'm needing to return an array from runCalendarScript(), but I'm not sure if I can return an array into the object like I'm trying to? I don't really understand how to "run" the runCalendarScript() from the controller? Thanks for any help! I'm stripping out most of the guts of the methods for the sake of brevity: controller: <?php class CalendarController extends Zend_Controller_Action { public function indexAction() { $finishedFeedArray = new Application_Model_Calendar(); $this->view->googleArray = $finishedFeedArray; } } model: <?php class Application_Model_Calendar { public function _runCalendarScript(){ $gcal = $this->_validateCalendarConnection(); $uncleanedFeedArray = $this->_getCalendarFeed($gcal); $finishedFeedArray = $this->_cleanFeed($uncleanedFeedArray); return $finishedFeedArray; } //Validate Google Calendar connection public function _validateCalendarConnection() { ... return $gcal; } //extracts googles calendar object into the $feed object public function _getCalendarFeed($gcal) { ... return $feed; } //cleans the feed to just text, etc protected function _cleanFeed($uncleanedFeedArray) { $contentText = $this->_cleanupText($event); $eventData = $this->_filterEventDetails($contentText); return $cleanedArray; } //Cleans up all formatting of text from Calendar feed public function _cleanupText($event) { ... return $contentText; } //filterEventDetails protected function _filterEventDetails($contentText) { ... return $data; } }

    Read the article

  • C# Custom Control Properties load before Load and arrays are empties

    - by Wildhorn
    Hello, I made a custom control with custom properties. When I modify these properties in the "Form.cs [Design]", I need stuff to happens (it fill some arrays and modify the look of the control), so I call a function within the "set" of the property. All of this works good. My problem is that when I run the program with my custom control, it seems that properties "set" is called, which will call the function, but then, my arrays seems now to have lost all their values and the function use these arrays, but now because they are all empty, it crashes due to NullException blahblahblah. It also seems that properties "set" is called before the control Load (which I guess is called only when it is added to my Form, and not when the Form load). So question is, why does my arrays become empty once I try to run the Form and is there an event that is called before that when the Form load? Thanks

    Read the article

  • Adding a textblock to a custom wpf control (piepiece control from codeplex)

    - by bomortensen
    Hi Stackoverflow! I'm currently building a Surface application where the main navigation is a circular menu. For each menu item I'm using a custom control that I found on codeproject.com: http://www.codeproject.com/KB/WPF/PieChartDataBinding.aspx (PiePiece control) The number of submenu items (which is also piepiece controls) comes from a database and thus dynamically loaded. What I can't figure out is how I add a textblock to this custom control to display the submenu item text. It needs to follow the PiePiece's RotationAngle property to line up correctly. Anyone got a hot-fix for this? I was thinking about adding another dependencyproperty to the piepiece custom control, but that way I can't set the font-family, size etc (can I?) Any input on this is greatly appreciated! Thanks!

    Read the article

  • Build model with nested model in rspec integration test

    - by user1116573
    I understand that I can do something like in rspec: let(:project) { Project.new } but in my app a project accepts_nested_attributes_for tasks and when I generate the Project form I build a task along with it using: @project = Project.new @project.tasks.build I need something like: let(:project) { Project.new.tasks.build } but that doesn't seem to work. How can I do this as a let in my rspec test?

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >