0

I have an embedded chromium client named CefSharp in my Windows Form Application. On application start, I am loading a webpage in cefsharp from project resources using following statement in c#:

 web_view.LoadHtml(File.ReadAllText(@".\HelloPage.html"), @".\HelloPage.html");

Page loads successfully. Now I have a button on webpage and I want to navigate to another page designed using jquery-mobile and added to the project resources on this button's click event. I have a button and link on my web page to load another pages as following:

<a id="myLink" class="ui-btn ui-corner-all ui-shadow ui-mini" href="Page2.html" >Rollout</a>

<button type="submit" id="submitData" runat="server" onclick="Page3.html;" class="ui-shadow ui-btn ui-corner-all ui-mini">Submit</button>

Both the above mentioned events gives me Error Loading Page. I tried another technique to call c# method from javascript and make a call to load my page inside that method but couldn't achieve that. Can anybody please help me with this. Its my first project on c#. I want to know where I am doing wrong or what other options do I have to make it work. Thanks in Advance.

4

2 回答 2

4

哥们,好远啊 我建议在有效的网页(本地或远程托管)中尝试您的代码。上面的代码:

onclick="Page3.html;"

不会工作得非常好。尝试在 onclick 中引用 js 函数,重点是 - 首先获取一个工作网页 - 最好引用外部资产,例如 js 文件和 css 样式表。

然后可以看cef的包装。通常,您需要将 Web 资产设置为嵌入式资源并使用

Assembly.GetManifestResourceStream

但你离那还有很长的路要走。首先专注于网页。

于 2014-03-17T15:28:00.567 回答
0

改变这个;

<button type="submit" id="submitData" runat="server" onclick="window.location.href='Page3.html';" class="ui-shadow ui-btn ui-corner-all ui-mini">Submit</button>
于 2016-06-28T15:31:51.993 回答