标签: webforms

使用Knockoutjs绑定对象列表

我正在尝试使用KnockoutJSKnockout 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)

c# asp.net webforms knockout-mapping-plugin knockout.js

1
推荐指数
1
解决办法
2117
查看次数

ASP NET会话抛出.ToString()错误

我在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# asp.net webforms

1
推荐指数
1
解决办法
2207
查看次数

我应该使用哪种"使用"在课堂上进行会话/请求?

我使用的是.NET/C#WebForm应用程序.我创建了一个类,我想使用该对象SessionRequest(我在.aspx页面上使用)没有前缀HttpContext.Current.

我想我可以通过使用导入一个类?但是哪个?

.net c# webforms class

1
推荐指数
1
解决办法
73
查看次数

方法参数的动态长度

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)

c# asp.net webforms

1
推荐指数
1
解决办法
31
查看次数

如何从代码后面将bool传递给JavaScript函数?

我有一个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)

但它似乎没有正常工作.谁能告诉我有什么问题?

javascript c# asp.net webforms boolean

1
推荐指数
1
解决办法
9818
查看次数

是否有一个始终在webform中调用的方法?

我需要包含这样的代码:

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使用代理....

.net c# webforms

1
推荐指数
1
解决办法
52
查看次数

如何调整Google RECAPTCHA的大小

我怎样才能调整recaptcha容器的大小,我的意思是我想保持一切规模,只是希望整个容器更小以适应移动视图.

原来的尺寸现在:

在此输入图像描述

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

在此输入图像描述

不想使用任何一种定制的主题或东西,只想让整个容器更小,说70%,任何想法怎么做?

css c# asp.net webforms recaptcha

1
推荐指数
1
解决办法
2767
查看次数

使用ASP.NET的webapp中的SSH终端

您好我创建了一个具有类似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)

c# asp.net ssh webforms

1
推荐指数
1
解决办法
4743
查看次数

调用的WebMethod与参数从jQuery的阿贾克斯失败

我对以下问题感到困惑.

我有一个"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)

ajax jquery webforms webmethod

1
推荐指数
1
解决办法
2万
查看次数

Fileupload正则表达式验证对于asp.net中的某些文件名失败

我使用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

我使用错误的验证表达式.我想允许任何带有扩展名的文件名,如上所述.

c# regex asp.net webforms

1
推荐指数
1
解决办法
6897
查看次数