Daily Archives

Articles indexed Friday February 25 2011

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

  • YouSendIt Alternative?

    - by WuckaChucka
    Looking for a reasonably priced alternative to YouSendIt's exorbitant pricing for an embedded, unbranded (i.e. no "Uploads by SomeCompany" or at the very least, discrete, subtle co-branding) file upload solution for my client's print shop Website. To do what we want to do with YouSendIt, we're looking at a corporate account of $995 USD plus $29.99 USD monthly fee, that is only sold pro-rated, so you have to buy the entire year's worth. To me, this is just unacceptable considering the commodity pricing of storage and bandwidth nowadays. For data, we're looking at roughly 10MB per upload, with perhaps 250-1000 uploads per month, with transient data storage of no more than 30 days (and more than likely 1-2 business days) for a total of 10 GB transfer (upload) and 10 GB transfer (download, to the print shop) at the very max each month. Any ideas? Everything I've found through searching seems to be geared more towards personal file sharing and not for embedding into Websites. Thanks

    Read the article

  • Video Encoding library for C++ game

    - by Paulo Pinto
    I'm looking for a video encoding library in C++ that I can use to record game footage. It can not be an external application like Fraps, it must be a library. Ideally the encoding can be done in real time without affecting game performance too much, although this is not a must have requirement. Another preference is that the video file being saved from the game is already compressed and ready to be used by most video players without any further processing. I realize that this might not be possible especially for real time encoding, so I would accept a trade off of having to process the file later for better compression and/or better file format. I'd like to hear about your experience integrating the library into a game if possible and any interesting trade offs you had to make. Some libraries support more that one file format or codec, so advice on the file format would also be appreciated.

    Read the article

  • How to go from mainstream to indie development?

    - by Salano Software
    I'm currently working as a game programmer for a AAA-level developer and publisher - which falls into the 'nice problem to have' category, I know, except that I'm growing more and more disenchanted with the direction of both the company and the AAA portion of the industry as a whole. I don't see any games on the studio's calendar for the next several years that I'm actually interested in working on; it looks like a continuing parade of sequels, license extensions and largely-derivative work. Which isn't to say that there won't be interesting things to do on those projects; but more and more I find myself wanting to do something fundamentally different. It seems like the market's never been better for smaller-scale projects, and I'd love to jump into that (and I've done small demos for Android and have started digging into iOS), but I obviously can't put anything out while I'm working for the company, and I'm concerned that I shouldn't even do substantial development in my spare time on anything I'd eventually like to release on my own. At the same time, I'm leery of leaving the job I've got for hopefully-obvious reasons, especially without a specific plan in place. Has anyone out there got experience with 'going indie' out of a mainstream job, and does anyone have specific suggestions as to what the best approach is and what I should specifically be thinking about or be careful of?

    Read the article

  • What are the fundamentals of game development?

    - by Matt
    Hi, I completely do not understand how a video game can be coded. I'm a beginner programmer and only have experience writing console applications that do math and what not. I do not understand how these logical processes can make images move on the screen (video games). Obviously if i jumped into a game development book or something like that I would understand but I am currently still getting a grasp of the fundamentals of programming in general. Could anyone give a simple explanation , coding wise, on the jump between making a computer do simple math to making a computer produce amazing graphical programs such as video games? Maybe there are some intro videos someone can point me to? I

    Read the article

  • accessing c++ class members with luaplus

    - by cppanda
    i've implemented LuaPlus in my engine eventmanager successfully and really like the flexibility i gained. but i'm still not exactly where i want to by, because i can't link my c++ classes to a lua class. for example i have a Actor class in c++, and i want to be able to create the same class in lua and gain access to members with luaplus, but i can't figure how i can achieve that. Is this actually luaplus built in functionality, or do i have to write my own interface that exchanges data tables between c++ and lua? my current approach would be to fire an event in luascript that creates an new actor class in c++ code, and transfer its id and the data i need to back to lua. when i modify the data i send the modifications back to c++ code again, but i actually thought there's something in luaplus that exposes this functionality already.

    Read the article

  • what the difference between break with label and without label in javascript

    - by dramasea
    <script type="text/javascript"> var num = 0; for(var i = 0; i < 10; i++){ for(var j = 0; j < 10 ; j++){ if(i == 5 && j == 5){ break; } num++; } } alert(num); </script> In the above code,i expect the result to be 55 but why the result is 95. But why if i added that the label, the result become 55?Can someone tell me thanks!! <script type="text/javascript"> var num = 0; outermost: for(var i = 0; i < 10; i++){ for(var j = 0; j < 10 ; j++){ if(i == 5 && j == 5){ break outermost; } num++; } } alert(num); </script>

    Read the article

  • Overloading '-' for array subtraction

    - by Chris Wilson
    I am attempting to subtract two int arrays, stored as class members, using an overloaded - operator, but I'm getting some peculiar output when I run tests. The overload definition is Number& Number :: operator-(const Number& NumberObject) { for (int count = 0; count < NumberSize; count ++) { Value[count] -= NumberObject.Value[count]; } return *this; } Whenever I run tests on this, NumberObject.Value[count] always seems to be returning a zero value. Can anyone see where I'm going wrong with this? The line in main() where this subtraction is being carried out is cout << "The difference is: " << ArrayOfNumbers[0] - ArrayOfNumbers[1] << endl; ArrayOfNumbers contains two Number objects. The class declaration is #include <iostream> using namespace std; class Number { private: int Value[50]; int NumberSize; public: Number(); // Default constructor Number(const Number&); // Copy constructor Number(int, int); // Non-default constructor void SetMemberValues(int, int); // Manually set member values int GetNumberSize() const; // Return NumberSize member int GetValue() const; // Return Value[] member Number& operator-=(const Number&); }; inline Number operator-(Number Lhs, const Number& Rhs); ostream& operator<<(ostream&, const Number&); The full class definition is as follows: #include <iostream> #include "../headers/number.h" using namespace std; // Default constructor Number :: Number() {} // Copy constructor Number :: Number(const Number& NumberObject) { int Temp[NumberSize]; NumberSize = NumberObject.GetNumberSize(); for (int count = 0; count < NumberObject.GetNumberSize(); count ++) { Temp[count] = Value[count] - NumberObject.GetValue(); } } // Manually set member values void Number :: SetMemberValues(int NewNumberValue, int NewNumberSize) { NumberSize = NewNumberSize; for (int count = NewNumberSize - 1; count >= 0; count --) { Value[count] = NewNumberValue % 10; NewNumberValue = NewNumberValue / 10; } } // Non-default constructor Number :: Number(int NumberValue, int NewNumberSize) { NumberSize = NewNumberSize; for (int count = NewNumberSize - 1; count >= 0; count --) { Value[count] = NumberValue % 10; NumberValue = NumberValue / 10; } } // Return the NumberSize member int Number :: GetNumberSize() const { return NumberSize; } // Return the Value[] member int Number :: GetValue() const { int ResultSoFar; for (int count2 = 0; count2 < NumberSize; count2 ++) { ResultSoFar = ResultSoFar * 10 + Value[count2]; } return ResultSoFar; } Number& operator-=(const Number& Rhs) { for (int count = 0; count < NumberSize; count ++) { Value[count] -= Rhs.Value[count]; } return *this; } inline Number operator-(Number Lhs, const Number& Rhs) { Lhs -= Rhs; return Lhs; } // Overloaded output operator ostream& operator<<(ostream& OutputStream, const Number& NumberObject) { OutputStream << NumberObject.GetValue(); return OutputStream; }

    Read the article

  • ASP.NET application using old connection string.

    - by Doug S.
    I am trying to publish a website using ASP.NET MVC3 EF and CODEFIRST with a SQL Server 2008 backend. On my local machine I was using a sql express db for development, but now that I am pushing live, I want to use my hosted production database. The problem is that when I try to run the application, it is still using my local db connection string. I have completely removed the old connection string from my web.config file and am using the <clear /> tag before creating the new connection string. I have also cleaned the solution and rebuilt, but somehow it is still connecting to the old db. What am I missing? This is the new connection string: <connectionStrings> <clear /> <add name="CellularAutomataDBContext" connectionString=" Server=XXX; Database=CellularAutomata; User ID=XXX; Password=XXX; Trusted_Connection=False" providerName="System.Data.SqlClient" /> </connectionStrings>

    Read the article

  • Use google analytics custom events for feedback form.

    - by chacko
    I was thinking of having a simple feedback form in my website. It would be something like: Your Feedback will help us improve. [ ] and then a textfield/textarea where the user can type (let's say) up to 100 characters of feedback. Rather than handling it all myself on the serverside I was thinking to use google analytics (since my site is already wireup) and everytime a user writes a comment send a custom event to google analytics. I think it might work. Can people suggest a better approach or point out any problem with this idea thanks

    Read the article

  • Methodologies or algorithms for filling in missing data

    - by tbone
    I am dealing with datasets with missing data and need to be able to fill forward, backward, and gaps. So, for example, if I have data from Jan 1, 2000 to Dec 31, 2010, and some days are missing, when a user requests a timespan that begins before, ends after, or encompasses the missing data points, I need to "fill in" these missing values. Is there a proper term to refer to this concept of filling in data? Imputation is one term, don't know if it is "the" term for it though. I presume there are multiple algorithms & methodologies for filling in missing data (use last measured, using median/average/moving average, etc between 2 known numbers, etc. Anyone know the proper term for this problem, any online resources on this topic, or ideally links to open source implementations of some algorithms (C# preferably, but any language would be useful)

    Read the article

  • Perl references not returning correct values

    - by martincarlin87
    Hi, this is my first time asking a question here so apologies if I am not following any conventions correctly. I encountered a bug in some Perl code that basically lost any parameters in the URL after the first name-value pair and the solution was to use the URI::Escape function on the URL. After this change I decided to move code that does this to a Perl module (Utils.pm) so that any future changes only need to be made once in this file, rather than have to update every file that uses it. The problem I seem to have is that the user, passwd and priv variables don't seem to return the correct values - the system still allows you to sign in but it can't identify your name or the privileges that you have. Below is a link to a pastebin of the code I believe to be relevant to the problem. I believe it is to do with the references but any changes I make just break the page! If anyone has any ideas I would greatly appreciate the help. http://pastebin.com/tqGfGutW

    Read the article

  • How to handle JSON response using SBJSON iPhone?

    - by Jay Mehta
    I am receiving the below response from my web service? Can any one has idea how to handle it using SBJSON? { "match_details" : { "score" : 86-1 "over" : 1.1 "runrate" : 73.71 "team_name" : England "short_name" : ENG "extra_run" : 50 } "players" : { "key_0" : { "is_out" : 2 "runs" : 4 "balls" : 2 "four" : 1 "six" : 0 "batsman_name" : Ajmal Shahzad * "wicket_info" : not out } "key_1" : { "is_out" : 1 "runs" : 12 "balls" : 6 "four" : 2 "six" : 0 "batsman_name" : Andrew Strauss "wicket_info" : c. Kevin b.Kevin } "key_2" : { "is_out" : 2 "runs" : 20 "balls" : 7 "four" : 4 "six" : 0 "batsman_name" : Chris Tremlett * "wicket_info" : not out } } "fow" : { "0" : 40-1 } } I have done something like this:

    Read the article

  • How to Deserialize this Xml file?

    - by Robin-Hood
    Hello experts, I have this Xml file, and I need to Deserialize it back to a class. The problem is: what is the right structure/design of this class considering that the count of the Xml element (RowInfo) is not constant? The Xml File: <?xml version="1.0"?> <SomeObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <Layers> <Layer Id="0"> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1</RowInfo> <RowInfo>1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</RowInfo> <RowInfo>1,1,1,0,0,1,1,1,1,1,1,1,1,1,0,0,1,0,0,1</RowInfo> <RowInfo>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1</RowInfo> </Layer> </Layers> </SomeObject> Appreciate your help. Thanks. Edit1:also considering that (Layers) may contains more than one layer.

    Read the article

  • Chnaging Displayed Image on a Webpage Using Javascript

    - by Gavin
    Hi all, I'm having some trouble changing an image being displayed on a page by way of a dropdown menu selection. This works fine.. getting the dropdown menu to give me an alert when I make a selection. Even though the menu is embedded within a division, paragraph, and label tag, it still works. "availableImages" is the name of my menu. function imageSelect() { var index = document.getElementById("myForm").availableImages.selectedIndex; var value = document.getElementById("myForm").availableImages.options[index].value; alert("test " + value); // alert box pops up upon list item selection } However, within the same division, I am having an issue with changing the source of my image tag... Any ideas? I will provide more code if it will be helpful. Thanks! Gavin

    Read the article

  • Reload images in a UIWebView after they have been downloaded by a background thread

    - by dantastic
    I have an application that frequently checks in with a server and downloads a batch of articles to the iphone. The articles are in html and just stored using core data. An article has 0-n images on the page. Downloading all associated images at the same time as the text will be too slow and take too much bandwidth. Users are not likely to open every article. If they open an article once it is likely they will open it several times. So I want to download and store the images locally when they are needed. These articles are listed in a UITableView. When you tap an article you pop open a UIWebView that displays the article. I have a function that checks if I have downloaded the images associated with the article already. If I have I just pop open the the UIWebView - everything works fine. If I don't have the images downloaded I go off and download them and store them to my Documents directory. Although this i working, the app is hanging while the images are downloading. Not very tidy. I want the article to open in a snap and download the images with the article open. So what I've done is I check if the images are downloaded, if they aren't I go ahead and just "touch" the files I need and load the webview. The UIWebView opens up but the images referenced contain no data. Then in a background thread I download the images and overwrite the "dummy" ones. This will save the images and everything but it won't reload the images in my current UIWebView. I have to go back out of the article back back in again to see the images. Are there any ways around this? reloading just an image in a UIWebView?

    Read the article

  • dialog jquery - pass php output to it, how ?

    - by Kamil Zytkiewicz
    I got this code /* Popup for hot news */ $(document).ready(function() { var $dialog = $('<div></div>') .html('text to be shown') .dialog({ autoOpen: false, title: 'Tablica nowosci' }); This code is in my js files included by header.php. How to pass php output to this function ? Inputing in .html('') above doesnt solve anything. Please help.

    Read the article

  • Selenium / FlashSelenium calling the wrong methods?

    - by bug-a-lot
    Seems like sometimes when Selenium should call a certain method, it instead calls another, as pointed out by the following log: 14:57:18.328 INFO - Command request: getEval[this.browserbot.findElement("someElement").doFlexClick('someIdOfAButton','');, ] on session 21708b0a4a154ebc96c9720c14578e74 14:57:18.343 INFO - Got result: OK,Error: Cannot type text into someIdOfAButton on session 21708b0a4a154ebc96c9720c14578e74 I've tried both Selenium server 1.0.3 and the 2.0 alpha 7 versions, they both display this behaviour. FlashSelenium is involved so I'm not sure where along the way lies the bug. Furthermore it's hard to reproduce as it doesn't happen only for some methods, and doesn't always happen. I've tried searching for issues similar to these but couldn't find any remotely similar... Anyone experienced the same behavior? And if so, is there a fix for it? Edit: I doubt FlashSelenium is at fault for this, as the log tells that the command arrives correctly at the server... But I can't seem to be able to follow the path of execution from the moment the Selenium server gets the command and passes over to the browser, to the moment where it gets the response.

    Read the article

  • MMGR Questions, code use and thread-saftey

    - by chadb
    1) Is MMGR thread safe? 2) I was hoping someone could help me understand some code. I am looking at something where a macro is used, but I don't understand the macro. I know it contains a function call and an if check, however, the function is a void function. How does wrapping "(m_setOwner (FILE,_LINE_,FUNCTION),false)" ever change return types? #define someMacro (m_setOwner(__FILE__,__LINE__,__FUNCTION__),false) ? NULL : new ... void m_setOwner(const char *file, const unsigned int line, const char *func); 3) What is the point of the reservoir? 4) On line 770 ("void *operator new(size_t reportedSize)" there is the line "// ANSI says: allocation requests of 0 bytes will still return a valid value" Who/what is ANSI in this context? Do they mean the standards? 5) This is more of C++ standards, but where does "reportedSize" come from for "void *operator new(size_t reportedSize)"? 6) Is this the code that is actually doing the allocation needed? "au-actualAddress = malloc(au-actualSize);"

    Read the article

  • C# MDX RenderToSurface, where to reset after device is lost?

    - by Moritz Schöfl
    Hi, I got a problem with the RenderToSurface class. When I resize the Form of my Device, the Draw method is still called, but doesnt throw an Exception, it looks like this: device.Clear(ClearFlags.Target, Color.Red, 0, 0); device.BeginScene(); // here is out commented code device.EndScene(); device.Present(); In another method, I wrote this: renderToSurface.BeginScene(surfaces[currentIndex]); // here is out commented code renderToSurface.EndScene(Filter.None); and this method seems to throw a nullpointer exception when I resize the window; So my question is: - where to reset / restore / handle the renderToSurface class? (i tried it with the DeviceReset event like following - void OnDeviceReset(object sender, EventArgs e) { renderToSurface = new RenderToSurface(Game.Device, Game.ClientSize.Width, Game.ClientSize.Height, Format.A8R8G8B8, true, DepthFormat.D16); } )

    Read the article

  • why do i lose my hidden field value?

    - by user517406
    Hi, I have some hidden fields on my page, all of which work fine apart from one. I am setting the value in document.ready, before calling buildGrid() : $(document).ready(function() { $.ajax( { type: "POST", url: "/CDServices.asmx/GetWeekEndingDates", data: "{}", dataType: "json", contentType: "application/json; charset=utf-8", success: function(msg) { //store default dates in hidden fields $("#<%=hdnCurrentDate.ClientID%>").val(msg.d.CurrentDate); $("#<%=hdnLastWeekEndingDate.ClientID%>").val(msg.d.LastWeekEndingDate); } }); buildGrid(); }); Yet in buildGrid, the value in the hidden field is empty : function buildGrid() { alert($("#<%=hdnLastWeekEndingDate.ClientID%>").val()); I call other functions on button clicks where the hidden field value is picked up fine, why does the value disappear here?

    Read the article

  • How to modyfy resource in a DLL from this DLL?

    - by CichyK24
    I'm writing an add-on for IE using VC++ and ATL. It's a simple DLL and I have a text file that I use as a resource. This answer helped me in doing this. I have a question about updating resource. MSDN describes how to do it but there is a function (BeginUpdateResource) that need filename of exe or dll with resource. Is it possible to update resource in my DLL from my DLL? I can easily read it that way, but to update I have to provide DLL's name. Is it necessary? Also if I won't give full path to my DLL it looks for file on desktop and not where DLL is stored. I don't know why this behave like this.

    Read the article

  • Why it is so difficult to find a good Ads SDK for Windows Phone 7

    - by help.net
    This post try to address an issue with the Microsoft Advertising SDK, the main fact that today Microsoft is still refusing access to the Ad Center worldwide. Yesterday they generously increase the number of free apps we can develop from 5 to 100. According to talks with other developers and the Windows Phone 7 team, I have the strong feeling the model of publishing free apps supported by apps is the right course to take today. This probably why Microsoft has moved to a bigger figure. Am I the only...(read more)

    Read the article

  • Coding4Fun Toolkit for WP7 Overview and Getting Started

    - by help.net
    This post is an overview of the new Coding4Fun Windows Phone Toolkit . It offers developers additional controls and helper classes for Windows Phone 7 application development, designed to match the rich user experience of the Windows Phone 7. The official Coding4Fun tools were released yesterday by the Microsoft Coding4fun team, as always the full source code and a sample test project are also available (the whole toolkit is completely FREE). Some of the "geeks" involved in this cool project are...(read more)

    Read the article

  • User is trying to leave! Set at-least confirm alert on browser(tab) close event!!

    - by kaushalparik27
    This is something that might be annoying or irritating for end user. Obviously, It's impossible to prevent end user from closing the/any browser. Just think of this if it becomes possible!!!. That will be a horrible web world where everytime you will be attacked by sites and they will not allow to close your browser until you confirm your shopping cart and do the payment. LOL:) You need to open the task manager and might have to kill the running browser exe processes.Anyways; Jokes apart, but I have one situation where I need to alert/confirm from the user in any anyway when they try to close the browser or change the url. Think of this: You are creating a single page intranet asp.net application where your employee can enter/select their TDS/Investment Declarations and you wish to at-least ALERT/CONFIRM them if they are attempting to:[1] Close the Browser[2] Close the Browser Tab[3] Attempt to go some other site by Changing the urlwithout completing/freezing their declaration.So, Finally requirement is clear. I need to alert/confirm the user what he is going to do on above bulleted events. I am going to use window.onbeforeunload event to set the javascript confirm alert box to appear.    <script language="JavaScript" type="text/javascript">        window.onbeforeunload = confirmExit;        function confirmExit() {            return "You are about to exit the system before freezing your declaration! If you leave now and never return to freeze your declaration; then they will not go into effect and you may lose tax deduction, Are you sure you want to leave now?";        }    </script>See! you are halfway done!. So, every time browser unloads the page, above confirm alert causes to appear on front of user like below:By saying here "every time browser unloads the page"; I mean to say that whenever page loads or postback happens the browser onbeforeunload event will be executed. So, event a button submit or a link submit which causes page to postback would tend to execute the browser onbeforeunload event to fire!So, now the hurdle is how can we prevent the alert "Not to show when page is being postback" via any button/link submit? Answer is JQuery :)Idea is, you just need to set the script reference src to jQuery library and Set the window.onbeforeunload event to null when any input/link causes a page to postback.Below will be the complete code:<head runat="server">    <title></title>    <script src="jquery.min.js" type="text/javascript"></script>    <script language="JavaScript" type="text/javascript">        window.onbeforeunload = confirmExit;        function confirmExit() {            return "You are about to exit the system before freezing your declaration! If you leave now and never return to freeze your declaration; then they will not go into effect and you may lose tax deduction, Are you sure you want to leave now?";        }        $(function() {            $("a").click(function() {                window.onbeforeunload = null;            });            $("input").click(function() {                window.onbeforeunload = null;            });        });    </script></head><body>    <form id="form1" runat="server">    <div></div>    </form></body></html>So, By this post I have tried to set the confirm alert if user try to close the browser/tab or try leave the site by changing the url. I have attached a working example with this post here. I hope someone might find it helpful.

    Read the article

  • Mobile enabled web apps with ASP.NET MVC 3 and jQuery Mobile

    - by shiju
    In my previous blog posts, I have demonstrated a simple web app using ASP.NET MVC 3 and EF Code First. In this post, I will be focus on making this application for mobile devices. A single web site will be used for both mobile browsers and desktop browsers. If users are accessing the web app from mobile browsers, users will be redirect to mobile specific pages and will get normal pages if users are accessing from desktop browsers. In this demo app, the mobile specific pages are maintained in an ASP.NET MVC Area named Mobile and mobile users will be redirect to MVC Area Mobile. Let’s add a new area named Mobile to the ASP.NET MVC app. For adding Area, right click the ASP.NET MVC project and  select Area from Add option. Our mobile specific pages using jQuery Mobile will be maintained in the Mobile Area. ASP.NET MVC Global filter for redirecting mobile visitors to Mobile area Let’s add an ASP.NET MVC Global filter for redirecting mobile visitors to Mobile area. The below Global filter is taken from the sample app http://aspnetmobilesamples.codeplex.com/ created by the ASP.NET team. The below filer will redirect the Mobile visitors to an ASP.NET MVC Area Mobile. public class RedirectMobileDevicesToMobileAreaAttribute : AuthorizeAttribute     {         protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext)         {             // Only redirect on the first request in a session             if (!httpContext.Session.IsNewSession)                 return true;               // Don't redirect non-mobile browsers             if (!httpContext.Request.Browser.IsMobileDevice)                 return true;               // Don't redirect requests for the Mobile area             if (Regex.IsMatch(httpContext.Request.Url.PathAndQuery, "/Mobile($|/)"))                 return true;               return false;         }           protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)         {             var redirectionRouteValues = GetRedirectionRouteValues(filterContext.RequestContext);             filterContext.Result = new RedirectToRouteResult(redirectionRouteValues);         }           // Override this method if you want to customize the controller/action/parameters to which         // mobile users would be redirected. This lets you redirect users to the mobile equivalent         // of whatever resource they originally requested.         protected virtual RouteValueDictionary GetRedirectionRouteValues(RequestContext requestContext)         {             return new RouteValueDictionary(new { area = "Mobile", controller = "Home", action = "Index" });         }     } Let’s add the global filer RedirectMobileDevicesToMobileAreaAttribute to the global filter collection in the Application_Start() of Global.asax.cs file   GlobalFilters.Filters.Add(new RedirectMobileDevicesToMobileAreaAttribute(), 1); Now your mobile visitors will be redirect to the Mobile area. But the browser detection logic in the RedirectMobileDevicesToMobileAreaAttribute filter will not be working in some modern browsers and some conditions. But the good news is that ASP.NET’s browser detection feature is extensible and will be greatly working with the open source framework 51Degrees.mobi. 51Degrees.mobi is a Browser Capabilities Provider that will be working with ASP.NET’s Request.Browser and will provide more accurate and detailed information. For more details visit the documentation page at http://51degrees.codeplex.com/documentation. Let’s add a reference to 51Degrees.mobi library using NuGet We can easily add the 51Degrees.mobi from NuGet and this will update the web.config for necessary configuartions. Mobile Web App using jQuery Mobile Framework jQuery Mobile Framework is built on top of jQuery that provides top-of-the-line JavaScript in a unified User Interface that works across the most-used smartphone web browsers and tablet form factors. It provides an easy way to develop user interfaces for mobile web apps. The current version of the framework is jQuery Mobile Alpha 3. We need to include the following files to use jQuery Mobile. The jQuery Mobile CSS file (jquery.mobile-1.0a3.min.css) The jQuery library (jquery-1.5.min.js) The jQuery Mobile library (jquery.mobile-1.0a3.min.js) Let’s add the required jQuery files directly from jQuery CDN . You can download the files and host them on your own server. jQuery Mobile page structure The basic jQuery Mobile page structure is given below <!DOCTYPE html> <html>   <head>   <title>Page Title</title>   <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a1.min.css" />   <script src="http://code.jquery.com/jquery-1.5.min.js"></script>   <script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script> </head> <body> <div data-role="page">   <div data-role="header">     <h1>Page Title</h1>   </div>   <div data-role="content">     <p>Page content goes here.</p>      </div>   <div data-role="footer">     <h4>Page Footer</h4>   </div> </div> </body> </html> The data- attributes are the new feature of HTML5 so that jQuery Mobile will be working on browsers that supporting HTML 5. You can get a detailed browser support details from http://jquerymobile.com/gbs/ . In the Head section we have included the Core jQuery javascript file and jQuery Mobile Library and the core CSS Library for the UI Element Styling. These jQuery files are minified versions and will improve the performance of page load on Mobile Devices. The jQuery Mobile pages are identified with an element with the data-role="page" attribute inside the <body> tag. <div data-role="page"> </div> Within the "page" container, any valid HTML markup can be used, but for typical pages in jQuery Mobile, the immediate children of a "page" are div element with data-roles of "header", "content", and "footer". <div data-role="page">     <div data-role="header">...</div>     <div data-role="content">...</div>     <div data-role="footer">...</div> </div> The div data-role="content" holds the main content of the HTML page and will be used for making user interaction elements. The div data-role="header" is header part of the page and div data-role="footer" is the footer part of the page. Creating Mobile specific pages in the Mobile Area Let’s create Layout page for our Mobile area <!DOCTYPE html> <html> <head>     <title>@ViewBag.Title</title>     <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />     <script src="http://code.jquery.com/jquery-1.5.min.js"></script>     <script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>     </head>      <body> @RenderBody()    </body> </html> In the Layout page, I have given reference to jQuery Mobile JavaScript files and the CSS file. Let’s add an Index view page Index.chtml @{     ViewBag.Title = "Index"; } <div data-role="page"> <div data-role="header">      <h1>Expense Tracker Mobile</h1> </div> <div data-role="content">   <ul data-role="listview">     <li>@Html.Partial("_LogOnPartial")</li>      <li>@Html.ActionLink("Home", "Index", "Home")</li>      <li>@Html.ActionLink("Category", "Index", "Category")</li>                          <li>@Html.ActionLink("Expense", "Index", "Expense")</li> </ul> </div> <div data-role="footer">           Shiju Varghese | <a href="http://weblogs.asp.net/shijuvarghese">Blog     </a> | <a href="http://twitter.com/shijucv">Twitter</a>   </div> </div>   In the Index page, we have used data-role “listview” for showing our content as List View Let’s create a data entry screen create.cshtml @model MyFinance.Domain.Category @{     ViewBag.Title = "Create Category"; }   <div data-role="page"> <div data-role="header">      <h1>Create Category</h1>             @Html.ActionLink("Home", "Index","Home",null, new { @class = "ui-btn-right" })      </div>       <div data-role="content">     @using (Html.BeginForm("Create","Category",FormMethod.Post))     {       <div data-role="fieldcontain">        @Html.LabelFor(model => model.Name)        @Html.EditorFor(model => model.Name)        <div>           @Html.ValidationMessageFor(m => m.Name)        </div>         </div>         <div data-role="fieldcontain">         @Html.LabelFor(model => model.Description)         @Html.EditorFor(model => model.Description)                   </div>                    <div class="ui-body ui-body-b">         <button type="submit" data-role="button" data-theme="b">Save</button>       </div>     }        </div> </div>   In jQuery Mobile, the form elements should be placed inside the data-role="fieldcontain" The below screen shots show the pages rendered in mobile browser Index Page Create Page Source Code You can download the source code from http://efmvc.codeplex.com   Summary We have created a single  web app for desktop browsers and mobile browsers. If a user access the site from desktop browsers, users will get normal web pages and get mobile specific pages if users access from mobile browsers. If users are accessing the website from mobile devices, we will redirect to a ASP.NET MVC area Mobile. For redirecting to the Mobile area, we have used a Global filer for the redirection logic and used open source framework 51Degrees.mobi for the better support for mobile browser detection. In the Mobile area, we have created the pages using jQuery Mobile and users will get mobile friendly web pages. We can create great mobile web apps using ASP.NET MVC  and jQuery Mobile Framework.

    Read the article

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