I'm a newbie. I pass a parameter from a UIViewController to another with this method:
FirstViewController:
string parameter = "test";
var navigation = ServiceLocator.Current.GetInstance<INavigationService>();
navigation.NavigateTo("SecondViewController", parameter);
And after I would like to get my parameter:
SecondViewController:
var nav = new NavigationService().Initialize(NavigationController);
UIViewController controller = nav.NavigationController.TopViewController ; //The UIKit.UIViewController that was navigated to
string param = (String)nav.GetAndRemoveParameter(controller);
But the parameter result is null. Where I make mistakes? How can I get my parameter?
I solved this error in this way:
var navigation = (NavigationService)ServiceLocator.Current.GetInstance<INavigationService>();
I must to use a cast before this line of code.
Thank you all
Related
I'm trying to create a ResetPassword Page and I need to create something like that!
myApi.azure.com/ResetPassword?hash=YYYYYYYYYYYYYY
I already know how to create a link to another controller, but that way it would trigger the Action just with the click, and what I need is pass the hash as parameter inside of that URL and them, call a controller!
var link = new Uri(Url.Link("ValidationEmailUser", new { Code = emailToken }));
Something like this:
public IHttpActionResult RedirectAction()
{
var urlFormat = string.Format("https://www3.olx.com.br/account/forgotten_password/?hash={0}", emailToken);
var location = new Uri(urlFormat);
return this.Redirect(location);
}
I am now trying to create a Calendar event for Android platform. I am using Xamarin Forms but writing platform specific code for creating event on Android.
I went through the docs http://developer.xamarin.com/guides/android/user_interface/calendar/
but I am getting the error "An object reference is required for the non-static field, method or property ... " for the following line.
ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues);
Any help will be greatly appreciated
Please have a look on below line and try it.
var uri = Forms.Context.ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues);
ContentResolver is a property of Activity, so you need an activity to call that method.
var eventValues = new ContentValues();
eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 1);
eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, "TITLE");
eventValues.Put(CalendarContract.Events.InterfaceConsts.EventLocation, "LOCATION");
eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, "DESCRIPTION");
eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, Java.Util.TimeZone.Default.ID);
eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, startTime);
eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend, endTime);
eventValues.Put(CalendarContract.Events.InterfaceConsts.AllDay, isDayLong);
var uri = _activity.ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues);
var id = uri.LastPathSegment;
You cann see, that ContentResolver property called on Activity object.
In a view of ClimateChartController I do this code:
#Html.ActionLink("Kies land", "ListCountries", "Continent" new {Selectedyear = #ViewBag.SchoolYear, continentId = #ViewBag.ContinentId})
So this should go to the method ListCountries of ContinentController, along with the given parameters.
Now this doesn't work, if I do it without the parameters it goes to the method but well, I need the parameters...
For now I resolved this by using the following method in ClimateChartController:
public ActionResult ListCountries(int selectedyear, int continentid)
{
return RedirectToAction("ListCountries", "Continent",
new { selectedYear = selectedyear, continentId = continentid });
}
This works as intended, but causes cluttering of code and isn't neat.
So how can I call a method of another controller and pass some parameters with it?
Try this:
#Html.ActionLink("Kies land", "ListCountries", "Continent" , null, new {Selectedyear = #ViewBag.SchoolYear, continentId = #ViewBag.ContinentId})
OR:
Html.ActionLink("Kies land", "ListCountries", "Continent", new {Selectedyear = #ViewBag.SchoolYear, continentId = #ViewBag.ContinentId}, null)
There are possible solutions here:
Why does Html.ActionLink render "?Length=4"
I'm using the C# Facebook library. With that i wanted to post something on my own wall, but i'm getting an error (as described in the title):
(OAuthException) (#803) Some of the aliases you requested do not
exist: access_token=438781769472xxxxxxxxxxxxxxxxxx
This is what i'm doing in code:
FacebookClient facebookClient = new FacebookClient(myAccessToken);
var args = new Dictionary<string, object>();
args["message"] = "Test message";
args["caption"] = "Caption";
args["description"] = "Description";
args["name"] = "Name";
args["picture"] = "";
args["link"] = "";
// Not sure which one to use, but both give same error
facebookClient.Post(appAccessToken+"/feed", args);
//facebookClient.Post(appAccessToken, args);
Anyone any idea what the problem might be and how i can solve this??
facebookClient.Post(appAccessToken+"/feed", args);
should change to
facebookClient.Post("<page_id>/feed", args);
You need add the page id to which you need to post
You don't need to add the appAccessToken parameter to the Post method parameter. Your post URL will be automatically appended with the myAccessToken value used when instantiating facebookClient. If you amend your call to be facebookClient.Post("/feed", args); it should work fine.
I have method that should return a set of data. But at last when returning data then error shows like :"can not convert type 'WebApplication1.Webrefernce13.DT_value[]' to 'WebApplication1.Webrefernce13.DT_value"
public class InputHelp
{
public DT_Value Priority()
{
WebReference13.DT_SM_InputHelp_Request IncomingtypeReq = new WebReference13.DT_SM_InputHelp_Request();
WebReference13.DT_SM_InputHelp IncomingTypeResp;
WebReference13.SI_CreateSM_OBService _proxy1 = new WebReference13.SI_CreateSM_OBService();
CookieContainer cookie = new CookieContainer();
_proxy1.Credentials = new NetworkCredential("xxxx", "xxxxx"); // use credential to acess to the SAP system
_proxy1.CookieContainer = cookie;
IncomingtypeReq.Mode = "Create";
IncomingtypeReq.Language = "EN";
IncomingtypeReq.OptionalText1 = "ZLFN";
IncomingtypeReq.OptionalText2 = "";
IncomingtypeReq.WSCallID = "223424dgdf";
IncomingTypeResp = _proxy1.SI_GetInputHelp(IncomingtypeReq);
DT_Value[] ab=new DT_Value[10];
ab= IncomingTypeResp.Priority;
return ab; // error is here
}
I will be grateful if you can help me on this issue.
change your method signature to
public DT_Value[] Priority(){...}
also
DT_Value[] ab=new DT_Value[10];
ab = IncomingTypeResp.Priority; //<-- something doesn't look right here.
if IncomingTypeResp.Priority is of type DT_Value[] then you can just do
DT_Value[] ab = IncomingTypeResp.Priority;
You've declared ab as an array of DT_Value, but the method returns DT_Value (a single DT_Value instance).
If you want Priority to return an array you should change the declaration to this:
public DT_Value[] Priority()
You are defining ab as an array of DT_Value but the method contract is to return only one DT_Value. If you want to return only the first value (if it exists), make your last line
return ab[0];
Declare like below and might help you:
DT_Value ab=new DT_Value;