Hi,
I have a textbox with a ajaxautocomplete extender,whenever user type anything list are populated ,and user select item from that list
I am storing value of the list item in hiddenfield as
OnClientItemSelected="setvalue"
<input type="hidden" runat="server" id="hdnValue">
function setvalue(source, eventArgs){
$("#hdnValue").val(eventArgs.get_value());
}
After this,User press save button,but when i debug the code , i can check the value is
assigned to the hidden field in the clientside, but when i debug server side ,the hidden field is empty
what wrong in the code,What are the different way to access client side data in server side in asp.net.Please help
aspx page
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterModule/NewInnerMaster.master"
AutoEventWireup="true" CodeFile="LocationMaster.aspx.cs"
Inherits="MasterModule_Test" EnableEventValidation="false" %>
<%@ Register Assembly="IdeaSparx.CoolControls.Web" Namespace="IdeaSparx.CoolControls.Web"
TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<%--validation Combobox--%>
<%-- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>--%>
<script type="text/javascript" language="javascript">
function CheckRecordExistBuilding(id, val) {
gbl = "";
if (val.trim() != "") {
if (gblautocomplete == 0) {
PageMethods.CheckBuildingExist(val, onSuccessBuilding, onFailure, id);
}
}
}
// set the destination textbox value with the ContactName
function onSuccessBuilding(result, context, methodName) {
var Buildingid = document.getElementById(context);
var hndblg = document.getElementById("ContentPlaceHolder1_ContentPlaceHolder1_hndblg");
var hndBuildingID = document.getElementById("ContentPlaceHolder1_ContentPlaceHolder1_hndBuildingID");
if (result.split("|")[0] == "1") {
hndBuildingID.value = result.split("|")[1];
return true
}
else {
var con = confirm("This Building Doesn't Exist in the Master. Do You Want To Add a New One ?");
if (con == true) {
PageMethods.InsertBuilding(Buildingid.value, onSuccededBuilding, onFailure);
}
else {
Buildingid.value = hndblg.value;
return false
}
}
}
function onSuccededBuilding(result) {
// debugger
var hndBuildingID = document.getElementById("ContentPlaceHolder1_ContentPlaceHolder1_hndBuildingID");
// hndBuildingID.value = result;
hndBuildingID.value = '008888'
}
function onFailure(error) {
}
</script>
<script language="JavaScript">
function OnItemSelectedBuilding(source, eventArgs) {
// debugger
var results = eval('(' + eventArgs.get_value() + ')');
// $get('ContentPlaceHolder1_ContentPlaceHolder1_hndBuildingID').innerText = parseInt(results);
var hndBuildingID = document.getElementById("ContentPlaceHolder1_ContentPlaceHolder1_hndBuildingID");
// hndBuildingID.value = results
hndBuildingID.value = "555555"
}
<%--Loading For popup--%>
</script>
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<div id="Div1" runat="server"
style="top: 300px; left: 600px; display:none; position:absolute;">
<img id="img1" alt="" src="waiting.gif" style="display: inline; height: 16px;" />
</div>
<div >
<div style="padding-removed 0px; padding-removed 10px; width: 1024px;">
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<div style=" height:329px;" id="Div2">
<asp:CoolGridView ID="CoolGridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound"
OnRowCommand="GridView1_RowCommand" ShowFooter="false" OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowEditing="GridView1_RowEditing" ToolTip="Click Here To Edit"
OnPageIndexChanging="GridView1_PageIndexChanging" Style="table-layout: fixed;"
Width="100%" Height="100%" CssClass="mGrid" DataKeyNames="LocationID" PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt" >
<AlternatingRowStyle CssClass="alt" />
<Columns>
<asp:BoundField HeaderText="Building" DataField="Bldg_Name" HeaderStyle-Width="130px" HeaderStyle-HorizontalAlign="Left" />
<asp:TemplateField HeaderText="Sub Location" HeaderStyle-Width="140px" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:HiddenField ID="hndbuilding" runat="server" Value='<%# Bind("bldgID") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle Font-Names="Calibri" Font-Size="12px" Width="1024px" BackColor="#000000"
HorizontalAlign="Center" ForeColor="White" />
</asp:CoolGridView>
<asp:Button ID="Button1" runat="server" OnClick="GridView1_OnClick" style="display:none;" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
<div >
<div ID="Div3" runat="server" BackColor="White" Style="display:inline; background-color :rgba(0,0,0,0.5); width:100%;height:100%; top:0; left:0; right:0;bottom:0;position:fixed;">
<div>
<div style="padding:20px; removed 30%; removed 38%; removed:fixed; background-color: white; opacity:1; box-shadow: 10px 10px 10px #5d5d5d;">
<table style="border: Solid 0px gray; background-color: #EAEAEA; width: 400px; height: 350px;"
cellpadding="0" cellspacing="0" border="0">
<tr>
<td nowrap="nowrap"
style="width: 100px; text-align: left; padding-removed 15px; padding-removed 5px;"
class="normaltd">
Building
</td>
<td nowrap="nowrap" style="width: 300px; text-align: left;" valign="top">
<asp:TextBox ID="TextBox7" runat="server"
style="width:276px; height:19px;" onkeypress="test();"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator10" ControlToValidate="ddlBuilding" ValidationGroup="S"
runat="server" ErrorMessage=""></asp:RequiredFieldValidator>
<div id="div8" onmouseover="setGblflag()" önmouseout="removeGblFlg()" ></div>
<asp:AutoCompleteExtender ID="AutoCompleteExtender11" runat="server"
DelimiterCharacters="" Enabled="True" ServiceMethod="GetBuilding"
TargetControlID="ddlbuilding" MinimumPrefixLength="1" FirstRowSelected="false"
CompletionInterval="500" onclientitemselected="OnItemSelectedBuilding"
CompletionListCssClass = "completionList"
CompletionSetCount="20" EnableCaching="true"
CompletionListHighlightedItemCssClass="itemHighlighted"
CompletionListItemCssClass="listItem" CompletionListElementID="divbuilding">
</asp:AutoCompleteExtender>
<asp:FilteredTextBoxExtender ID="FilteredTextBoxExtender11"
runat="server"
TargetControlID="ddlBuilding"
FilterMode="InvalidChars"
InvalidChars="+.*/~`_={[}]|\?><,>)(!@#$%^&:;'" >
</asp:FilteredTextBoxExtender>
</td>
</tr>
<tr>
<td nowrap="nowrap" colspan="2" style="width: 400px; padding-removed5px;padding-removed5px;">
<table style="width: 400px; height: 40px; background-color: #EAEAEA;" border="0">
<tr>
<td style="text-align: left; width: 198px; padding-removed 3px; padding-removed 18px;">
<asp:Button ID="Button4" runat="server" style="display:none"/>
<asp:Button ID="Button5" runat="server" Text="Cancel" OnClientClick="closePopUp(); return false;"
Width="120px" Height="35px" ToolTip="Don't Save & Exit"
CssClass="areapopupbtncancel" BorderColor="#FF9900" ValidationGroup="lS" />
</td>
<td style="width: 300px; height: 50px; text-align: right; padding-removed 22px;">
<asp:Button ID="Button6" CommandName="Update" Height="35px" Width="150px" runat="server"
Text="Done" OnClick="btnUpdate_Click" CssClass="areapopupbtndone"
BorderColor="#ED7D31" ValidationGroup="S" ToolTip="Save Data" />
<asp:Button ID="Button7" CommandName="New" Height="35px" Width="150px" runat="server"
Text="Done" OnClick="btnNew_Click" CssClass="areapopupbtndone"
BorderColor="#ED7D31" ValidationGroup="S" ToolTip="Save Data" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div align="center"
style=" display:none; padding:20px; removed 39%; removed 48%; removed:fixed; z-index: 105;" id="Div10" class="modalPopup" >
<img alt="loading.." src="waiting.gif" /><div>
</div>
</div>
<div align="center"
style=" display:none; padding:20px; removed 64%; removed 57%; removed:fixed; z-index: 105;" id="Div11" >
<img alt="loading.." src="button.gif" />
<div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
protected void Page_Load(object sender, EventArgs e)
{
if (pnlpopup.Visible == false)
{
pnlpopup.Visible = false;
}
else
{
pnlpopup.Visible = true;
}
ScriptManager.RegisterStartupScript(this, this.GetType(), "starScript", "HideScroll();", true);
ddlCompany.Attributes.Add("onBlur", "CheckRecordExist(this.id,this.value);");
ddlCity.Attributes.Add("onBlur", "CheckRecordExistCity(this.id,this.value);");
ddlarea.Attributes.Add("onBlur", "CheckRecordExistArea(this.id,this.value);");
ddlBuilding.Attributes.Add("onBlur", "CheckRecordExistBuilding(this.id,this.value);");
ddlfloor.Attributes.Add("onBlur", "CheckRecordExistFloor(this.id,this.value);");
ddlsubcategory.Attributes.Add("onBlur", "CheckRecordExistSubLocation(this.id,this.value);");
if (!IsPostBack)
{
GetData();
pnlpopup.Visible = false;
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
LocationDTO objdto = new LocationDTO();
//Update the record here
UpdateLocation();
// this.ModalPopupExtender1.Hide();
pnlpopup.Visible = false;
GetData();
}
public void UpdateLocation()
{
try
{
LocationBLL objbll = new LocationBLL();
LocationDTO objdto = new LocationDTO();
objdto.LocationID = HFLDlocationID.Value;
objdto.LocationHeading = txtLocationHeading.Text;
objdto.CompanyID = hndCompanyID.Value.ToString() == "" ? ddlCompany.Text : hndCompanyID.Value;
objdto.CityID = hndCityID.Value.ToString() == "" ? ddlCity.Text : hndCityID.Value;
objdto.Areaid = hndAreaID.Value.ToString() == "" ? ddlarea.Text : hndAreaID.Value;
objdto.BldgID = hndBuildingID.Value.ToString() == "" ? ddlBuilding.Text : hndBuildingID.Value.Replace(" ", "");
//if (ddlfloor.Text == "")
//{
// hndFloorID.Value = "";
//}
//objdto.FloorID = hndFloorID.Value.ToString() == "" ? ddlfloor.Text : hndSubLocationID.Value.Replace(" ", "");
if (ddlfloor.Text == "")
{
hndFloorID.Value = "";
}
objdto.FloorID = hndFloorID.Value.ToString() == "" ? ddlfloor.Text : hndFloorID.Value.Replace(" ", "");
if (ddlsubcategory.Text == "")
{
hndSubLocationID.Value = "";
}
objdto.SubLocationID = hndSubLocationID.Value.ToString() == "" ? ddlsubcategory.Text : hndSubLocationID.Value.Replace(" ", "");
int objupdto = objbll.updateLocationMaster(objdto);
clearAllField();
}
catch (Exception ex)
{
throw ex;
}
}
protected void GridView1_OnClick(object sender, EventArgs e)
{
btnNew.Visible = false;
btnUpdate.Visible = true;
Button buttonSender = sender as Button;
int index;
GridViewRow row = null;
if (int.TryParse(Request.Params.Get("__EVENTARGUMENT"), out index))
{
row = GridView1.Rows[index];
Label area = (Label)GridView1.Rows[index].FindControl("lblarea");
ddlBuilding.Text = row.Cells[6].Text.Replace(" ", "");
HiddenField hndbuilding = (HiddenField)GridView1.Rows[index].FindControl("hndbuilding");
hndbuilding.Value.ToString();
hndblg.Value = row.Cells[6].Text;
pnlpopup.Visible = true;
}
}