Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Froblem regarding Ajax

Froblem regarding Ajax

Scheduled Pinned Locked Moved ASP.NET
helphtmlsysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yogesh m
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • Y 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

      G Offline
      G Offline
      GaryWoodfine
      wrote on last edited by
      #2

      Just wondering why you have chosen to use the HTMLText writer to add the control?

      Kind Regards, Gary


      My Website || My Blog || My Articles

      Y 1 Reply Last reply
      0
      • G GaryWoodfine

        Just wondering why you have chosen to use the HTMLText writer to add the control?

        Kind Regards, Gary


        My Website || My Blog || My Articles

        Y Offline
        Y Offline
        yogesh m
        wrote on last edited by
        #3

        HI want HTML return by the server ... So i written

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups