Click here to Skip to main content
16,021,125 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I am setting the textbox value through javascript code but when i am trying to fetching that value from textbox to database it is not getting anything..when i debug the code the check command parameter value its empty.Please tell me how can i do this..


C#
using (SqlCommand cmd = new SqlCommand("insertTrusteeInfoSP", con))
{
    cmd.CommandType = CommandType.StoredProcedure;
    //cmd.Parameters.AddWithValue("@TrusteeInformationId", Convert.ToInt32(txtEmployeeId.Text));
    cmd.Parameters.AddWithValue("@EmployeeReferenceId", txtlinemanager.Text);
    cmd.Parameters.AddWithValue("@TrusteeName", txtTrusteeName.Text.);
    //cmd.Parameters.AddWithValue("@TrustInformationId", Session["TrustInformationId"].ToString());
    // cmd.Parameters.AddWithValue("@TrustInformationId", Session["TrustInformation"].ToString());
    if (chkIsDefaultSign.Checked)
    {
        cmd.Parameters.AddWithValue("@IsDefaultSignatory", true);
    }
    else
    {
        cmd.Parameters.AddWithValue("@IsDefaultSignatory", false);
    }
    if (CheckIsActive.Checked)
    {
        cmd.Parameters.AddWithValue("@IsActive", true);
    }
    else
    {
        cmd.Parameters.AddWithValue("@IsActive", false);
    }
    cmd.Parameters.AddWithValue("@Description", txtdescription.Text);
    con.Open();
    result = cmd.ExecuteNonQuery();
    con.Close();

My javascript code


XML
<script type="text/javascript">
        function OpenPopup(showPopupFor) {
            var popupGenerator = null;
            var trusteeName = null;
            popupGenerator = document.getElementById("<%= txtlinemanager.ClientID %>");
            trusteeName = document.getElementById("<%= txtTrusteeName.ClientID %>");


            if (popupGenerator == null) return false;
            var url = employeesearch.aspx";
            var params = new Array(popupGenerator.Value);
            var popupSetting = "center:yes;scroll:no;edge=raised;status:no;resizable:no;dialogWidth:400px;dialogHeight:415px";
            var prevReturnValue = window.returnValue;
            window.returnValue = undefined;
            var pmx = window.showModalDialog(url, params, popupSetting);
            if (pmx == undefined) {
                pmx = window.returnValue;
            }
            window.returnValue = prevReturnValue;
            if (pmx == undefined || pmx == null) {
                popupGenerator.value = "";
            }
            else {
                // popupGenerator.value = pmx.toString();
                popupGenerator.value = pmx[0].toString();
                trusteeName.value = pmx[1].toString();
            }
            //popupGenerator.focus();
            return false;
        }

    </script>


on running on browser value is being shown in txtlinemanager textbox but when i am adding this value on command parameters it shows empty.
Posted
Updated 19-Nov-13 21:47pm
v2
Comments
Thanks7872 20-Nov-13 2:50am    
And we are supposed to assume your code?
JoCodes 20-Nov-13 3:39am    
Add your code using Improve question...
ajays3356 20-Nov-13 4:24am    
Hello JoCodes,
I have updated my question..
JoCodes 20-Nov-13 5:07am    
Check whether your textbox is disabled or readonly?
ajays3356 20-Nov-13 5:17am    
The problem is solved through asp hidden feild control..

use Hideen field ..asign textbox value to hidden field, than use this hidden field value in code behind
 
Share this answer
 
Comments
ajays3356 20-Nov-13 4:25am    
can you show me an any example to use hidden fields..
send the code where u r calling this function
function OpenPopup(showPopupFor) {<br />
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900