Froblem regarding Ajax
-
HI problem regarding ajax .. Inside ajax Method I use code to bind data .. Code is as follow [Ajax.Method] public string GetCity(int stateId ) { MenuDirectory.BLL .MasterData objMaster=new MenuDirectory.BLL.MasterData (); DataSet dsCity=objMaster.GetCitiesForState(stateId); DataRow dr=dsCity.Tables[0].NewRow(); dr["cityId"]=0; dr["cityName"]="Select City"; dsCity.Tables[0].Rows.InsertAt(dr,0); dropDownResCity.DataSource=dsCity.Tables[0]; dropDownResCity.DataTextField="cityName"; dropDownResCity.DataValueField="cityId"; dropDownResCity.DataBind(); HtmlTextWriter testWriter = null; dropDownResCity.RenderControl(testWriter); return testWriter.ToString(); } I got error on line "dropDownResCity.RenderControl(testWriter);" As Control 'dropDownRestCity' of type DropDownList must be place inside form tag with run at = "Server" where and my control is inside form tag The html for AspX as follow AjaxCall function CallFillCity(objCity) { //alert(obj.value); var obj = document.getElementById("dllCity"); //alert(obj.innerHTML); //alert(objCity.value); CityHtml = My.Page.GetCity(objCity.value); //alert(CityHtml.value); obj.innerHTML = CityHtml.value; }
Any know solution ... yogesh M
-
HI problem regarding ajax .. Inside ajax Method I use code to bind data .. Code is as follow [Ajax.Method] public string GetCity(int stateId ) { MenuDirectory.BLL .MasterData objMaster=new MenuDirectory.BLL.MasterData (); DataSet dsCity=objMaster.GetCitiesForState(stateId); DataRow dr=dsCity.Tables[0].NewRow(); dr["cityId"]=0; dr["cityName"]="Select City"; dsCity.Tables[0].Rows.InsertAt(dr,0); dropDownResCity.DataSource=dsCity.Tables[0]; dropDownResCity.DataTextField="cityName"; dropDownResCity.DataValueField="cityId"; dropDownResCity.DataBind(); HtmlTextWriter testWriter = null; dropDownResCity.RenderControl(testWriter); return testWriter.ToString(); } I got error on line "dropDownResCity.RenderControl(testWriter);" As Control 'dropDownRestCity' of type DropDownList must be place inside form tag with run at = "Server" where and my control is inside form tag The html for AspX as follow AjaxCall function CallFillCity(objCity) { //alert(obj.value); var obj = document.getElementById("dllCity"); //alert(obj.innerHTML); //alert(objCity.value); CityHtml = My.Page.GetCity(objCity.value); //alert(CityHtml.value); obj.innerHTML = CityHtml.value; }
Any know solution ... yogesh M
Just wondering why you have chosen to use the HTMLText writer to add the control?
Kind Regards, Gary
My Website || My Blog || My Articles
-
Just wondering why you have chosen to use the HTMLText writer to add the control?
Kind Regards, Gary
My Website || My Blog || My Articles