Page 1 of 1

How to get the QueryString? [SOLVED]

Posted: Wed Sep 30, 2015 7:52 am
by h82258652
I want to get the query string for the url. But I don't know how to do this, is any code or sample can help me? :(

Re: [Need Support]How to get the QueryString?

Posted: Wed Sep 30, 2015 8:39 am
by JS-Support @Userware
Hi,

Sure!

To get the query string, please use the following method:

Code: Select all

public static string GetQueryString()
{
    if (CSharpXamlForHtml5.Environment.IsRunningInJavaScript)
    {
        string url = JSIL.Verbatim.Expression("window.location.toString()");
        string queryString = (url.IndexOf('?') >= 0 ? url.Substring(url.IndexOf('?') + 1) : "");
        return queryString;
    }
    else
    {
        MessageBox.Show("The query string cannot be obtained when running inside the Simulator.");
        return "";
    }
}

Regards,
JS-Support

Re: [Need Support]How to get the QueryString?

Posted: Wed Sep 30, 2015 9:08 pm
by h82258652
JS-Support wrote:Hi,

Sure!

To get the query string, please use the following method:

Code: Select all

public static string GetQueryString()
{
    if (CSharpXamlForHtml5.Environment.IsRunningInJavaScript)
    {
        string url = JSIL.Verbatim.Expression("window.location.toString()");
        string queryString = (url.IndexOf('?') >= 0 ? url.Substring(url.IndexOf('?') + 1) : "");
        return queryString;
    }
    else
    {
        MessageBox.Show("The query string cannot be obtained when running inside the Simulator.");
        return "";
    }
}

Regards,
JS-Support


Thanks a lot!