我正在编写 iOS 应用程序来访问网站上的数据。它有用户名和密码。到目前为止,我无法以编程方式登录网站。下面是登录按钮的aspx代码
<div class="formRow formRowFull">
<label class="formLabel span4">
</label>
<input type="submit" name="ctl00$ContentPlaceHolder1$btnSubmit" value="Log in" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$btnSubmit", "", true, "required", "", false, false))" id="ContentPlaceHolder1_btnSubmit" class="mrg14 inputButton" />
<a data-fancybox-type="iframe" class="noteupload1" target="_parent" href="Forgot-Password.aspx" title="Forgot Password">
Forgot Password ?</a>
</div>
我试过下面的代码
[self.webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('ContentPlaceHolder1_btnSubmit').submit();"];
和
[self.webView stringByEvaluatingJavaScriptFromString: @"WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$btnSubmit", "", true, "required", "", false, false))"];
上面的代码用于使用 html。我猜 WebForm_DoPostBackWithOptions 是 .NET 框架方法。我在下面找到了与此 http://www.carlosag.net/articles/webparts/whidbey-faq 和 http://plainoldstan.blogspot.in/2007/06/story-of-client-side-validation-in相关的链接.html 但我不太了解。
如何以编程方式单击此按钮?