不能读取文本框的值 [英] Not able to read the text box value

查看:191
本文介绍了不能读取文本框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我AjaxFileUpload1.The问题的pageupload活动期间将数值从页面上的文本框中的变量是,我没有得到从文本框中的值,以我的变量,即使没有错误throws.My变量

I am assigning the value to the variable from the text box on the page during the pageupload event of AjaxFileUpload1.The problem is that, I am not getting the value from the text box to my variable even though no error throws.My variables are

        string scn = txtSCN.Text;
        string line1 = txtLineitem.Text;
        string aging1 = txtAging.Text;  

任何想法,为什么 AjaxFileUpload1_UploadComplete 是无法读取的文本框的值

Any idea why AjaxFileUpload1_UploadComplete is not able to read text box value

我的CS code是:

My cs Code is:

    protected void AjaxFileUpload1_UploadComplete(object sender,     AjaxControlToolkit.AjaxFileUploadEventArgs e)
         {
   string c = System.IO.Path.GetFileName(e.FileName);
        string dpath = "~/Profile/Images/";
        string scn = txtSCN.Text;
        string line1 = txtLineitem.Text;
        string aging1 = txtAging.Text;             
        AjaxFileUpload1.SaveAs(MapPath(Path.Combine(dpath,c)));
        dpath = dpath + c;
        string str1 = ConfigurationManager.ConnectionStrings["ProTracConnGMCH"].ConnectionString;
        SqlConnection cn = new SqlConnection(str1);
        cn.Open();
        string sql = "Update tbNoquoteFollowupupdate set MailreceivedURL = '" + dpath + "', chkMailreceived = 1 , Buyername =  '" + buyername + "'  where scn = '" + scn + "' AND lineItem = '" + line1 + "' and Aging ='" + aging1 + "' ";
        SqlCommand cmd = new SqlCommand(sql, cn);
        int i = cmd.ExecuteNonQuery();

        if (i > 0)
        {
           // AjaxFileUpload1.SaveAs(Path.Combine(dpath, e.FileName));
            //AjaxFileUpload1.SaveAs(MapPath(dpath));
        }
        cn.Close();
        BindGridviewData1();
        cn.Open();
        string cmd2 = "Insert Into tbMulitmailsreived (scn, lineItem,followupdate, Aging,MailreceivedURL) Values ('" + scn + "', '" + line1 + "','" + DateTime.Now + "','" + aging1 + "','" + dpath + "')";
        SqlCommand sqlCommand2 = new SqlCommand(cmd2, cn);
        sqlCommand2.ExecuteNonQuery();
        cn.Close();
    }

请帮我

推荐答案

我花了一些时间,上周调查这个<一href="http://stackoverflow.com/questions/21752542/cant-get-text-from-textbox-in-method-for-ajaxfileupload1-uploadcomplete">question但到底能不能找到这样的一个简单的解决方案。在这个问题的任择议定书解决它通过存储在Session值,但这个工作,你仍然需要进行回传在某个阶段。

I spent some time last week investigating this question but in the end couldn't find an easy solution for this. The OP in that question solved it by storing values in the Session but for this to work you would still need to cause a postback at some stage.

目前显然是功能计划在AjaxFileUpload控制的背景下键集合传递值,但这是从来没有的实施。该<一href="http://stackoverflow.com/questions/13080186/how-can-i-use-the-contextkeys-property-for-the-ajaxfileupload-control">question介绍如何,虽然自己实现。

There apparently was functionality planned for the AjaxFileUpload control to pass values in the Context Keys collections but this was never implemented. This question describes how to implement this yourself though.

我的认为的我看到了另一个问题,围绕同一主题和OP通过改变使用<一个解决它href="http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/AsyncFileUpload/AsyncFileUpload.aspx"相对=nofollow> AsyncFileUpload 控制,但我坚持要纠正...

I think I saw another question around the same topic and the OP solved it by changing to using the AsyncFileUpload control but I stand to be corrected...

这篇关于不能读取文本框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆