This is a very general and noob question, but I am a noob with real programming so...
How can I set a Boolean setting and store that setting so that when you exit the app and come back the setting is how the user left it? I also need to know how to read that setting and enable features based on them.
I plan to have two settings in my app, one for location and one for turning off an alert on attempting to exit the app (I know this is considered bad by most people, but trust me, it makes sense for this app).
I have no idea how to do this, things like this and cookies have always confounded me, so a good explanation would be greatly appreciated.
My app is in C# and XAML if that helps.
Might want to take a look at this article: http://dotnet.dzone.com/articles/using-application-settings
And this other SO question: When should I save settings on Windows Phone 7?
Use this code:
// save value
IsolatedStorageSettings.ApplicationSettings["MyName"] = true;
// read value
var val = IsolatedStorageSettings.ApplicationSettings.Contains("MyName")
? (bool) IsolatedStorageSettings.ApplicationSettings["MyName"]
: false; // false is default value
I like MSDN binding-based example:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769510(v=vs.105).aspx
(Thanks to Dmitry T. for the link on SO.)
Related
Hi all I have done some google work and not come up with a great deal apart from using the browser within a From which I dont want to do.
Has anybody some sample code or a good resource that is detailed enough to get me on my way plesae
So for example
Process.Start("https://www.google.com")
and target the search element with a string and click search.
Using the default browser
Please help me...
Doing something like this would work:
string mySearchQuery = "this is a search example";
Process.Start("https://www.google.com/search?q=" + Uri.EscapeDataString(mySearchQuery));
If I'm understanding you correctly, this would use the default browser set in windows, then the query is just passed in as a GET request (that's the ?q variable).
Im at my wits end trying to find a problem with a html/javascript page that acts like a widget that wont load in ie6 or ie7.. Would anyone be able to point me in the right direction on this?
http://cdn.xas.com/SampleOutput.html
Im guessing its some problem with some of my javascript?
I am building up the html in javascript, it could also be the html thats generated from this yes?
thanks
Neil
There are no offers displayed as dataCollection.Offers passed into function core.createOffersList, sourced from this.eventData in the BoonCentral.Com.Cdn.Widget, class is an empty array. As assigned by line 494:
this.eventData = {"Address":"10 Wellington Quay Jamestown, Dublin","ID":48,"LogoUrl":"http:\/\/www.booncentral.com\/VenueImages\/48\/201209171247\/0e8ed5bd-6076-4b67-a96a-5365cf225636the_workmans_club_dublin_28659.gif","Name":"The Workmans","Offers":[],"VenueProfile":"<p> <\/p><p>Dublin's most excellent new live music venue, situated in the heart of \u000d\u000athe city and open Monday to Sunday from 5pm til, well, when we kick you \u000d\u000aout!<\/p>"};
For IE6, you may be hitting this issue: http://kmleeblog.wordpress.com/2011/07/20/document-createelement-problem-in-ie6/
Hope this helps you narrow down the problem :-).
Although this doesn't answer your question- Why are you trying to make it work on IE6/7 ?
IE6 & 7 are barely used and are being phased out.
You're better off spending your time optimizing for current browsers..
According to http://www.theie7countdown.com/, the worldwide usage of IE7 is 4%.
According to http://www.w3schools.com/browsers/browsers_explorer.asp , it's now less than 1%.
With regards to this specific widget/project, is it taking you more than 1-4% of your time to address this issue?
Just my thoughts...
All-
I've been trying to search and find a solution for a while but I'm still stumped on 2 questions
1) Basically lets say I have this key:
System.Windows.Forms.Keys.A
And I want to send it using SendMessageto a window where the keyboard layout could be ANYTHING. It could be US-EN, or DE, or BE, anything.
How can I achieve this? Right now the windows are interpretting the key differently based on their regional settings.
I thought maybe KeysConverter but I don't see a function that would help with this.
2) Lets say I just have a list of keys, how can I convert them to the correct codes (virtual?) to pass to SendMessage?
Thanks in advance!
I would like to clear the search box in metro search charm after the user accepted one of the result suggestion my app is providing to the charm. How? Sounds easy but it is not, SearchPane.QueryText is read only.
I am actually surprised by the default system behavior. After the user accepted the ResultSuggestion (please remember to distinguish from QuerySuggestion) it does not make sense in my eyes to pre-populate the search box with this accepted result...
Try
var searchPane = Windows.ApplicationModel.Search.SearchPane.getForCurrentView();
searchPane.trySetQueryText("myQueryText");
The user's text stays there in case after looking at one of the results they decide "oh that's not it, I will look at this other result from" and the other result could even be from a different app. There is no way for an app to override this.
On this site if you do too many clicks or post comments too fast or something like that you get redirected to the "are you a human" screen. Does anybody know how to do something similar?
It's almost certainly a heuristic that tries to "guess" that a user is some form of automated process, rather than a person, for example:
More than "x" requests to do the same thing in a row
More than "x" actions in a "y" period of time
Ordinarily the "x" and "y" values would be formulated to be ones that it would be unlikely for a "real person" to do, like:
Editing the same answer 5 times in a row
Downvoting 10 questions within 1 minute
Once you've got your set of rules, you can then implement some code that checks them at the start of each request, be it in a method that's called in Page_Load, something in your masterpage, something in the asp.net pipeline, that's the easy bit! ;)
Here is a very nice Captcha Control for asp.net that first of all you need
http://www.codeproject.com/KB/custom-controls/CaptchaControl.aspx
Then you can use it together with this idea that try to find the dos attacks
http://weblogs.asp.net/omarzabir/archive/2007/10/16/prevent-denial-of-service-dos-attacks-in-your-web-application.aspx
be ware of a bug in this code in line if( context.Request.Browser.Crawler ) return false;, its must return true, or totally remove it for sure.
and make it your compination for the clicks, or submits.
If a user make too many clicks on a period of time, or many submits, then you simple open the capthaControl, and if the clicks are by far too many, then triger the dos attact. This way you have 2 solution in one, Dos attact prevent, with captcha at the same time.
I have made somthing similar my self, but I have change the source code of both, a lot to feet my needs.
One more interesting link for a different code for the dos attack.
http://madskristensen.net/post/Block-DoS-attacks-easily-in-ASPNET.aspx
Hope this help you.
At a guess...
Write a HTTP handler that records requests and store them in session.
When a new request comes in, check to see how many requests are stored (and expire old ones).
If the amount of requests in the past few minutes exceeds a given threshold, redirect the user.
If you're doing this in ASP.NET webforms, you could do this check on the site master page, ( or write a IHttpHandler).
If you're using an MVC framework, you could write a base controller that does this check for every action.
With rails, you could write a before_request filter.
With asp.net MVC, you could write a [ActionFilterAttribute] attribute
You should have a session to track the user activity.
In session you can have counter for commenting and posting like:
(pseudo code instead of C#, sorry :)
if (post_event) {
posts_during_1_minute_interval++;
if (time_now-reference_time > 1_minute) {
reference_time = time_now;
posts_during_1_minute_interval=0;
}
}
...
if (posts_during_1_minute_interval > 10) redirect("/are-you-human.htm");
where on are-you-human.htm page you can have recaptcha, as they have here on StcakOverflow.com
see also:https://blog.stackoverflow.com/2009/07/are-you-a-human-being/
just check how many hit / minutes you get from a specific ip or session or whatever and decide what are your preferred threshold and your good to go
I'd also check the user agent header of the request - if it doesn't look like a popular browser (or is empty) then throw the "are you a human?" page.