Daily Archives

Articles indexed Wednesday April 7 2010

Page 13/131 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Passing URL parameter and a form data together

    - by Fabio
    I have following URL: http://localhost:49970/Messages/Index/9999 And at view "Index" I have a form and I post the form data to the action Index (decored with [HttpPost]) using Jquery, like this: View: <script type="text/javascript"> function getMessages() { var URL = "Index"; $.post( URL, $("form").serialize(), function(data) { $('#tabela').html(data); } ); } </script> <% using (Html.BeginForm()) {%> <%=Html.TextArea("Message") %> <input type="button" id="submit" value="Send" onclick="javascript:getMessages();" /> <% } %> Controller: [HttpPost] public ActionResult Index(FormCollection collection) { //do something... return PartialView("SomePartialView", someModel); } My question: How can I get the parameter "9999" and the form FormCollection in the action Index? PS: Sorry about my english :)

    Read the article

  • What is mangling tinyurls?

    - by djn
    Hello all. I've noticed that some form processors make a mess out of posted TinyURLs (converting the thing to a broken 'tinyurl": "http:\/?\/?tinyurl.com\/?whatever", "ok": tr') while leaving alone other plain URLs. I've seen it happen in WordPress, and I've seen it here on SO (eg.: http://stackoverflow.com/questions/2508690/whats-the-most-efficient-way-to-setup-a-multi-lingual-website - second comment to first answer). Has anybody looked into what component or function is doing this? Is there a way to prevent it?

    Read the article

  • UITableView: NSMutableArray not appearing in table

    - by Michael Orcutt
    I'm new to objective c and iPhone programming. I can't seem to figure out why no cells will fill when I run this code. The xml content displays in the console log and xcode displays no errors. Can any help? - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { if(![elementName compare:@"Goal"] ) { tempElement = [[xmlGoal alloc] init]; } else if(![elementName compare:@"Title"]) { currentAttribute = [NSMutableString string]; } else if(![elementName compare:@"Progress"]) { currentAttribute = [NSMutableString string]; } } - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if(![elementName compare:@"Goal"]) { [xmlElementObjects addObject:tempElement]; } else if(![elementName compare:@"Title"]) { NSLog(@"The Title of this event is %@", currentAttribute); [tempElement setTitled:currentAttribute]; } else if(![elementName compare:@"Progress"]) { NSLog(@"The Progress of this event is %@", currentAttribute); [tempElement setProgressed:currentAttribute]; } } - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if(self.currentAttribute) { [self.currentAttribute appendString:string]; } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [xmlElementObjects count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [mtableview dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; } // Set up the cell... cell.textLabel.text = [xmlElementObjects objectAtIndex:indexPath.row]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { }

    Read the article

  • When should I use $ (and can it always be replaced with parentheses)?

    - by J Cooper
    From what I'm reading, $ is described as "applies a function to its arguments." However, it doesn't seem to work quite like (apply ...) in Lisp, because it's a binary operator, so really the only thing it looks like it does is help to avoid parentheses sometimes, like foo $ bar quux instead of foo (bar quux). Am I understanding it right? Is the latter form considered "bad style"?

    Read the article

  • What are the primitive Forth operators?

    - by Barry Brown
    I'm interested in implementing a Forth system, just so I can get some experience building a simple VM and runtime. When starting in Forth, one typically learns about the stack and its operators (DROP, DUP, SWAP, etc.) first, so it's natural to think of these as being among the primitive operators. But they're not. Each of them can be broken down into operators that directly manipulate memory and the stack pointers. Later one learns about store (!) and fetch (@) which can be used to implement DUP, SWAP, and so forth (ha!). So what are the primitive operators? Which ones must be implemented directly in the runtime environment from which all others can be built? I'm not interested in high-performance; I want something that I (and others) can learn from. Operator optimization can come later. (Yes, I'm aware that I can start with a Turing machine and go from there. That's a bit extreme.) Edit: What I'm aiming for is akin to bootstrapping an operating system or a new compiler. What do I need do implement, at minimum, so that I can construct the rest of the system out of those primitive building blocks? I won't implement this on bare hardware; as an educational exercise, I'd write my own minimal VM.

    Read the article

  • Oracle: What does `(+)` do in a WHERE clause?

    - by Jonathan Lonowski
    Found the following in an Oracle-based application that we're migrating (generalized): SELECT Table1.Category1, Table1.Category2, count(*) as Total, count(Tab2.Stat) AS Stat FROM Table1, Table2 WHERE (Table1.PrimaryKey = Table2.ForeignKey(+)) GROUP BY Table1.Category1, Table1.Category2 What does (+) do in a WHERE clause? I've never seen it used like that before.

    Read the article

  • null coalescing operator for javascript?

    - by Daniel Schaffer
    I assumed this question has already been asked here, but I couldn't find any, so here it goes: Is there a null coalescing operator in Javascript? For example, in C#, I can do this: String someString = null; var whatIWant = someString ?? "Cookies!"; The best approximation I can figure out for Javascript is using the conditional operator: var someString = null; var whatIWant = someString ? someString : 'Cookies!'; Which is sorta icky IMHO. Can I do better?

    Read the article

  • What were the hot languages of 2009?

    - by geowa4
    It is well-accepted that we should all learn something new every six months. But what should should have topped the list for 2009? What new things should we learn have learned this year that appear to have real staying power? (Answers do not have to be limited to languages.)

    Read the article

  • check if a domain is blacklisted / blocked

    - by Henry
    Some clients report to us that our site is not accessible through their internet connection. We suspect our site is wrongfully blocked by some security software/firewall/public blacklist. How can we verify that, other than trying them one by one? There are so many security software out there that it is not practical... Thx

    Read the article

  • Remote Socket Read In Multi-Threaded Application Returns Zero Bytes or EINTR (104)

    - by user39891
    Hi. Am a c-coder for a while now - neither a newbie nor an expert. Now, I have a certain daemoned application in C on a PPC Linux. I use PHP's socket_connect as a client to connect to this service locally. The server uses epoll for multiplexing connections via a Unix socket. A user submitted string is parsed for certain characters/words using strstr() and if found, spawns 4 joinable threads to different websites simultaneously. I use socket, connect, write and read, to interact with the said webservers via TCP on their port 80 in each thread. All connections and writes seems successful. Reads to the webserver sockets fail however, with either (A) all 3 threads seem to hang, and only one thread returns -1 and errno is set to 104. The responding thread takes like 10 minutes - an eternity long:-(. *I read somewhere that the 104 (is EINTR?), which in the network context suggests that ...'the connection was reset by peer'; or (B) 0 bytes from 3 threads, and only 1 of the 4 threads actually returns some data. Isn't the socket read/write thread-safe? I use thread-safe (and reentrant) libc functions such as strtok_r, gethostbyname_r, etc. *I doubt that the said webhosts are actually resetting the connection, because when I run a single-threaded standalone (everything else equal) all things works perfectly right, but of course in series not parallel. There's a second problem too (oops), I can't write back to the client who connect to my epoll-ed Unix socket. My daemon application will hang and hog CPU 100% for ever. Yet nothing is written to the clients end. Am sure the client (a very typical PHP socket application) hasn't closed the connection whenever this is happening - no error(s) detected either. Any ideas? I cannot figure-out whatever is wrong even with Valgrind, GDB or much logging. Kindly help where you can.

    Read the article

  • Using jquery validate with multiple fields of the same name

    - by Matt H
    I am trying to get jquery validate to work on multiple fields. Reason being I have dynamically generated fields added and they are simply a list of numbers. So I thought I'd put together a basic example and followed the concept from the accepted answer in the following link: http://stackoverflow.com/questions/931687/using-jquery-validate-plugin-to-validate-multiple-form-fields-with-identical-name However, it's not doing anything useful. Why is it not working? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/lib/jquery.delegate.js"></script> <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script> <script> $("#submit").click(function(){ $("field").each(function(){ $(this).rules("add", { required: true, email: true, messages: { required: "Specify a valid email" } }); }) }); $(document).ready(function(){ $("#myform").validate(); }); </script> </head> <body> <form id="myform"> <label for="field">Required, email: </label> <input class="left" id="field" name="field" /> <input class="left" id="field" name="field" /> <input class="left" id="field" name="field" /> <input class="left" id="field" name="field" /> <br/> <input type="submit" value="Validate!" id="submit" name="submit" /> </form> </body> </html>

    Read the article

  • Dataset field DBNull -> int?

    - by BobClegg
    SQLServer int field. Value sometimes null. DataAdapter fills dataset OK and can display data in DatagridView OK. When trying to retrieve the data programmatically from the dataset the Dataset field retrieval code throws a StronglyTypedException error. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public int curr_reading { get { try { return ((int)(this[this.tableHistory.curr_readingColumn])); } catch (global::System.InvalidCastException e) { throw new global::System.Data.StrongTypingException("The value for column \'curr_reading\' in table \'History\' is DBNull.", e); } Got past this by checking for DBNull in the get accessor and returning null but... When the dataset structure is modified (Still developing) my changes (unsurprisingly) are gone. What is the best way to handle this situation? It seems I am stuck with dealing with it at the dataset level. Is there some sort of attribute that can tell the auto code generator to leave the changes in place?

    Read the article

  • Unicode and PHP - am I doing something wrong?

    - by alex
    I'm using Kohana 3, which has full support for Unicode. I have this as the first child of my <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> The Unicode character I am inserting into is é as in Café. However, I am getting the triangle with a ? (as in could not decode character). As far as I can tell in my own code, I am not doing any string manipulation on the text. In fact, I have placed the accent straight into a view's PHP file and it is still not working. I copied the character from this page: http://www.fileformat.info/info/unicode/char/00e9/index.htm I've only just started examining PHP's Unicode limitations, so I could be doing something horribly wrong. So, how do I display this character? Do I need to resort to the HTML entity?

    Read the article

  • Get the ID of a Child in a cascade="all" relationship, while adding it to a collection, in Hibernate

    - by Marco
    Hi, i have two Entities, "Parent" and "Child", that are linked through a bidirectional one-to-many relationship with the cascade attribute set to "all". When adding a Child object to the Parent children collection using the code below, i can't get the ID of the persisted child until i commit the transaction: Parent p = (Parent) session.load(Parent.class, pid); Child c = new Child(); p.addChild(c); // "c" hasn't an ID (is always zero) However, when i persist a child entity by explicitly calling the session.save() method, the ID is created and set immediately, even if the transaction hasn't been committed: Child c = new Child(); session.save(c); // "c" has an ID Is there a way to get the ID of the child entity immediately without calling the session.save() method? Thanks

    Read the article

  • What is the best way to store incremental downloaded data?

    - by afriza
    Inspired by Chromium's sha1 class, I am thinking to store incrementally downloaded data using std::string // pseudo-code char buff[BUFF_SIZE]; std::string data; do { size = ReadInternetFileTo(buff,BUFF_SIZE); data.append(buff,size); } while (not_finished); Any foreseeable problems with this method or better way to do it?

    Read the article

  • jQuery Validate - can I re-validate a group of fields after changing one?

    - by Nathan Long
    I'm using jQuery Validate and would like to re-validate a group of fields whenever one of them is changed (or possibly, whenever one of them validates successfully). My attempts so far just create infinite loops. Is this possible, or does the plugin design preclude it? (Specifically, I've got a method that requires at least X of group Y to be filled out, and as soon as that's true, I'd like all those fields to re-validate. Currently I'm clearing out their error messages with my own code, but that's a hack - it also hides unrelated validation problems until the form is re-submitted.)

    Read the article

  • Nullable Enum nullable type question

    - by Michael Kniskern
    I get the following compilation error with the following source code: Compilation Error: Type of conditional expression cannot be determined because there is no implicit conversion between '' and 'MyEnum' Source Code public enum MyEnum { Value1, Value2, Value3 } public class MyClass { public MyClass() {} public MyEnum? MyClassEnum { get; set; } } public class Main() { object x = new object(); MyClass mc = new MyClass() { MyClassEnum = Convert.IsDBNull(x) : null ? (MyEnum) Enum.Parse(typeof(MyEnum), x.ToString(), true) }; } How can I resolve this error?

    Read the article

  • Integrating Codeigniter and Objective C

    - by Mike
    I'm currently building a social networking site using the codeIgniter PHP framework. One of our major focuses of this site is to be able to upload images through the use of smartphones. We were focusing on building for the iPhone, but the iPhone doesn't let you upload files for some reason beyond me. I have been looking through solutions for days seeing if we could somehow integrate an iPhone app and have come up with nothing. The only thing I have found is using Cocoa Xcode in Objective C to somehow get around the fact. Now I don't know anything about objective C and I was wondering if I could somehow integrate a snippet of objective C into my PHP to allow users to upload photos off their iPhone and onto our site. Is this possible? If so how? If not, does anyone know another work around?

    Read the article

  • Best way to databind a Winforms control to a nullable type?

    - by Steve Hiner
    I'm currently using winforms databinding to wire up a data editing form. I'm using the netTiers framework through CodeSmith to generate my data objects. For database fields that allow nulls it creates nullable types. I've found that using winforms databinding the controls won't bind properly to nullable types. I've seen solutions online suggesting that people create new textbox classes that can handle the nullable types but that could be a pain having to swap out the textboxes on the forms I've already created. Initially I thought it would be great to use an extension method to do it. Basically creating an extension property for the textbox class and bind to that. From my limited extension method experience and doing a bit of checking online it looks like you can't do an extension property. As far as I can tell, binding has to be through a property since it needs to be able to get or set the value so an extension method wouldn't work. I'd love to find a clean way to retrofit these forms using something like extension methods but if I have to create new textbox and combo box controls that's what I'll do. My project is currently limited to .Net 2.0 due to the requirement to run on Windows 2000. Any suggestions?

    Read the article

  • Nullable<> as TModel for ViewPage

    - by Alexander Prokofyev
    What are the possible reasons what Nullable<> types are disallowed to be passed as TModel parameter of System.Web.Mvc.ViewPage<TModel> generic? This could be handy sometimes. In ASP.NET MVC source defined what TModel should be a class: public class ViewPage<TModel> : ViewPage where TModel : class but Nullable types are value types. Maybe definition could be less restrictive...

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >