0

I have a variable called "cb" in my C# class file, I want to use it in my HTML page using JavaScript function.

Here Is my C# code

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
        string str = "ms-appx-web:///homepage.html";
        wview.Navigate(new Uri(str, UriKind.Absolute));

    }
    public string cb = "";
    public async void init(object sender, NotifyEventArgs e)
    {
        string val = e.Value;
        if (val == "picture")
        {
            try
            {
                cb = await ocrchild.picture();
                Debug.WriteLine("Image saved at :- " + cb);                    
            }
            catch (Exception ee)
            {
                Debug.WriteLine(ee.Message);
            }
        }
    }
}

and this is my html code, I want that cb to be in stored in i4 variable, Can you help me with this?

<script>
    function CallNative()
    {
        var i1=document.getElementById("id1").checked;
        var i2=document.getElementById("id2").checked;
        var i3 = document.getElementById("id3").checked;
        var i4 = "";

        if(i1== true)
        {
            window.external.notify("picture");
        }
        if (i2 == true) {
            window.external.notify("ocr");
        }
        if (i3 == true) {
            window.external.notify("base64");
        }
        document.getElementById("id4").value = i4;
    };


</script>

Thanks in advance.

7
  • it is easly accessed in javascript. you have add hidden field or label in aspx page and set a value in cs page. another option if you use html page then you will call ajax method. Commented Jun 6, 2017 at 9:03
  • Thanks for your reply, But can You explain this more clearly Commented Jun 6, 2017 at 9:20
  • Please you clearyfy that you have html page or aspx page. Commented Jun 6, 2017 at 9:29
  • i have html page Commented Jun 6, 2017 at 9:43
  • you should use query string . e.g htttp://myhtmlpahe.html?id=123 Commented Jun 6, 2017 at 9:44

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.