我正在尝试使用KnockoutJS和Knockout Mapping将数据绑定到ASP.NET Webforms Application
HTML
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="Scripts/knockout-2.3.0.js" type="text/javascript"></script>
<script src="Scripts/knockout.mapping-latest.js" type="text/javascript"></script>
<script type="text/javascript">
function bindModel(data) {
var viewModel;
viewModel = ko.mapping.fromJS(data);
console.log(viewModel);
ko.applyBindings(viewModel);
}
$(document).ready(function () {
$.ajax({
url: "TestPage.aspx/GetItems",
data: {},
type: "POST",
contentType: "application/json",
dataType: "JSON",
timeout: 10000,
success: function (result) {
bindModel(result);
},
error: function (xhr, status) {
alert(status + " - " + xhr.responseText);
}
});
});
</script>
...
<table>
<thead>
<tr>
<th>
Id
</th>
<th>
Name
</th>
</tr> …Run Code Online (Sandbox Code Playgroud) 我在IE9中的项目ASp.NEt c#中使用Session有问题.有时会出现错误:"对象引用未设置为对象的实例"
其他问题是在IE9中,有时候不会保存我的Session以将Idiom更改为其他页面.在Chrome中一切都很好!


下面是我的Page_Load和CarregaGrid().此问题有时发生,没有时间发生,并且在任何页面中都没有出现在所有页面中或只出现在一个特定页面中.
public void CarregaGrid()
{
var listByGroupM = new ManageUsers().ConsultUsersGroupM();
if (listByGroupM != null)
{
this.GridView1.DataSource = listByGroupM;
if (listByGroupM.Count != 0)
{
this.GridView1.DataBind();
GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
}
}
if (divModify.Visible == true)
{
foreach (GridViewRow row in GridView1.Rows)
{
string idioma = CultureInfo.CurrentCulture.TwoLetterISOLanguageName.ToString();
if (Session["idioma"].ToString() != null)
{
idioma = Session["idioma"].ToString();
}
Idioma.MudaCultura(idioma);
Button btnDelete = (Button)row.FindControl("btnDelete");
btnDelete.Text = Idioma.RetornaMensagem("btnDelete");
string UserName = row.Cells[1].Text;
PrincipalContext insPrincipalContext = new PrincipalContext(ContextType.Domain, "x.com", "x", "xxx");
UserPrincipal insUserPrincipal = UserPrincipal.FindByIdentity(insPrincipalContext, …Run Code Online (Sandbox Code Playgroud) 我使用的是.NET/C#WebForm应用程序.我创建了一个类,我想使用该对象Session或Request(我在.aspx页面上使用)没有前缀HttpContext.Current.
我想我可以通过使用导入一个类?但是哪个?
Page.aspx:
<a href="#" <%= ToggleUiVisibility(new List<bool>() { true, true, false }) %> >
link
</a>
Run Code Online (Sandbox Code Playgroud)
C#:
public string ToggleUiVisibility(List<bool> conditions)
{
return conditions.Any(x=>!x) ? "style=\"display:none;\"" : string.Empty;
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否可以做类似的事情(伪代码)
ToggleUiVisibility(true, true, argsN);
public string ToggleUiVisibility(args)
{
// make sure each argument is a bool and trigger the same
// functionality as above
}
Run Code Online (Sandbox Code Playgroud) 我有一个JavaScript函数如下:
function A(bNeed)
{
if (bNeed){
...
}
else{
...
}
}
Run Code Online (Sandbox Code Playgroud)
在我的代码背后Page_Load,我有
bool bNeed = File.Exists(...);
btn.Attributes.Add("onclick", string.Format("return A('{0}');", bNeed));
Run Code Online (Sandbox Code Playgroud)
但它似乎没有正常工作.谁能告诉我有什么问题?
我需要包含这样的代码:
IWebProxy proxy = new WebProxy(Proxy, ProxyPort);
NetworkCredential nc = new NetworkCredential();
nc.UserName = ProxyLogin;
nc.Password = ProxyPassword;
proxy.Credentials = nc;
WebRequest.DefaultWebProxy = proxy;
Run Code Online (Sandbox Code Playgroud)
在我的WebForm应用程序中.但我项目的很多部分都是从不同的地方开始的:不同的主页,用ajax调用的单页等等!
我可以把它放在一个共同的地方吗?所以每次调用页面都能保证我的WebRequest使用代理....
我怎样才能调整recaptcha容器的大小,我的意思是我想保持一切规模,只是希望整个容器更小以适应移动视图.
原来的尺寸现在:

在移动视图上看起来并不好看:

不想使用任何一种定制的主题或东西,只想让整个容器更小,说70%,任何想法怎么做?
您好我创建了一个具有类似Putty的SSH终端的webapp.我使用SSH库作为处理ssh流的方法.但是有一个问题.我可以登录到Cisco 2950并输入命令,但它会混乱并且在一行中.此外,当我尝试"conf t"时,它进入配置终端,但是你不能做任何事情,这会弹出"Line有无效的自动命令"?".
这是我到目前为止的代码:
这是与库交互的SSH.c.
public class SSH
{
public string cmdInput { get; set; }
public string SSHConnect()
{
var PasswordConnection = new PasswordAuthenticationMethod("username", "password");
var KeyboardInteractive = new KeyboardInteractiveAuthenticationMethod("username");
// jmccarthy is the username
var connectionInfo = new ConnectionInfo("10.56.1.2", 22, "username", PasswordConnection, KeyboardInteractive);
var ssh = new SshClient(connectionInfo);
ssh.Connect();
var cmd = ssh.CreateCommand(cmdInput);
var asynch = cmd.BeginExecute(delegate(IAsyncResult ar)
{
//Console.WriteLine("Finished.");
}, null);
var reader = new StreamReader(cmd.OutputStream);
var myData = "";
while (!asynch.IsCompleted)
{
var result …Run Code Online (Sandbox Code Playgroud) 我对以下问题感到困惑.
我有一个"WebForm1.aspx的"和"WebService1.asmx".当我在WebService WITHOUT参数('HelloWorld')中调用WebMethod时,它工作正常.当我调用Method WITH参数('SayHello')时,它失败了.
它甚至没有命中方法(我没有达到方法中设置的断点).xmlHttpRequest错误是"内部服务器错误"
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public string SayHello(string firstName, string lastName)
{
return "Hello " + firstName + " " + lastName;
}
}
Run Code Online (Sandbox Code Playgroud)
我WebForms1.aspx:
<div><br />No Parameters </div>
<div id="NoParameters"></div>
<div><br />With Parameters</div>
<div id="WithParameters"></div>
<script type="text/javascript"> …Run Code Online (Sandbox Code Playgroud) 我使用fileupload控件上传文件,同时使用正则表达式验证文件名.
我想要上传以下文件扩展名,以便.doc, .docx, .pdf 我使用以下命令来查看有效文件名
ValidationExpression="[a-zA-Z\\].*(.doc|.DOC|.docx|.DOCX|.pdf|.PDF)$"
<asp:FileUpload ID="FileUpload1" runat="server" CssClass="fileUpload" />
<asp:RequiredFieldValidator ID="ValidateF1" runat="server" ErrorMessage="*" CssClass="row-validate" ControlToValidate="FileUpload1"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="ValidateEx" runat="server" ValidationExpression="[a-zA-Z\\].*(.doc|.DOC|.docx|.DOCX|.pdf|.PDF)$" ControlToValidate="FileUpload1" ValidationGroup="Careers" ErrorMessage="*"></asp:RegularExpressionValidator>
Run Code Online (Sandbox Code Playgroud)
它无法验证以下文件名
(K)+J01461+abced+high+En+(HR)(1).pdf 我不知道为什么它失败了 ABC_COMPANY_Privacy_v4.0_123456(5).pdf
我使用错误的验证表达式.我想允许任何带有扩展名的文件名,如上所述.