Join Dotnetcodes DotnetCodes.com is online Discussion Forum for Software professionals . It lets you find friends around the world and Create professional network that share similar interests as you. Get help on ur projects by industry specialists. Also get answers to all ur technical/placement related querries.Get an edge over others.
Already MemberClick here to login
ASP.net MVC Interview Questions Answers Interview Questions
Get Started Developing for Android Apps with Eclipse Articles
Serial Number in SSRS Articles
.Net framework 4.0 Interview Questions Answers Interview Questions
SQL server reporting services Interview Questions (SSRS) part 1 Articles
Whats New in ASP.NET 4.0 Part 2 Articles
How to Print a Crystal Report direct to printer Articles
Difference between Encapsulation and Abstraction Interview Questions
Explaining SDLC -System Development Life Cycle Articles
Html5 interview questions and answers Interview Questions
SharePoint 2010 interview Questions Answers Interview Questions
Infosys Interview Questions Interview Questions
Dynamic Menu using HTML List Tag and CSS in ASP.Net Articles
Populate or bind Dropdownlist in Asp.net using Jquery and Json Articles
ASP.NET MVC Overview Interview Questions
Submit Articles | More Articles..

Updateing asp.net webform using ajax

Posted By: michc on 6/11/2012 8:27:04 AM | Comments:0 [Forward This]
I have an asp.net webform which has a div element and a textbox on it. The div is loaded with some html, which I've retrieved into a string in the codebehind file. Inside this html, I need to be able to mark up various bits of text so that when a user clicks them, it sends a message back to the server, which then populates the text box (which is on the same form) with some other data. The problem I'm having is how best to communicat back to the server- so in the code below, 1) What should the line alert("You clicked " + x); be, so that it uses ajax to call back to the server, sending the parameter 'hello' 2) What method would be invoked on the server? Would it be Page_Load again? 3) After having called the server, what code would I need to popluate the text box without sending back the whole page again (i.e. still using ajax)? The problem is not retrieving the text on the server, let's just say I receive 'hello' as a parameter on the server, and want to send back 'goodbye' to the text box, again using ajax So my source aspx file has this in it... <div id="contents" runat="server"></div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> and in my codebehind file in form_load, I have.. System.IO.StreamReader rdr = System.IO.File.OpenText("c:\\myHtmlFile.html"); string s = rdr.ReadToEnd(); this.contents.InnerHtml = s; the HTML I'm loading into the div element is this <script type="text/javascript"> function myfunction(x) { alert("You clicked " + x); } </script> <p onclick="myfunction('hello')">hello</p> When the user clicks 'hello', I want TextBox1 to say 'goodbye'. Again, it's the server that has to handle things here, without reposting the webpage though.. Anyone have any ideas? The simpler the better please! thanks in advance!
Read CommentsComments Category:AJAX Reply to this PostReply

Dear Friends, Dont forget to bookmark and submit your posting to social websites listed above.It will bring more visibility, buzz and fast action to attend your post

Responses to the Discussion: Updateing asp.net webform using ajax
 No Responses found
You have not Logged In,  click here to Login
Reply Here
 
, I agree the terms and conditions of this website
  
Similar Discussion
Updateing asp.net webform using ajax    Asked by: michc
How to call web service?    Asked by: rakesh
Ask Questions | All Similar Discussions..
  .NET Framework
  ADO.NET
  AJAX
  Android
  ASP.NET
  ASP.NET AJAX
  ASP.NET MVC
  Azure
  Best Practices
  BizTalk Server
  C++
  CSharp
  CSS
  DBMS
  Error and Resolution
  HTML
  IIS
  JAVA
  JavaScript
  JQwery
  JSP
  LINQ
  Management
  Mobile
  ODP.NET
  OOPS
  Oracle
  Others
  Pattern and Practices
  PHP
  SAP
  SEO
  SharePoint
  Silverlight
  Sql Server
  SSAS
  SSIS
  SSRS
  Survey
  UML
  UNIX
  VB
  VB.NET
  VS 2010
  WCF
  Web Analytics
  Windows Forms
  WPF
  WWF
  XML
  XSLT
  .NET Framework
  ADO.NET
  AJAX
  Android
  ASP.NET
  ASP.NET AJAX
  ASP.NET MVC
  Azure
  Best Practices
  BizTalk Server
  C++
  CSharp
  CSS
  DBMS
  Error and Resolution
  HTML
  IIS
  JAVA
  JavaScript
  JQwery
  JSP
  LINQ
  Management
  Mobile
  ODP.NET
  OOPS
  Oracle
  Others
  Pattern and Practices
  PHP
  SAP
  SEO
  SharePoint
  Silverlight
  Sql Server
  SSAS
  SSIS
  SSRS
  Survey
  UML
  UNIX
  VB
  VB.NET
  VS 2010
  WCF
  Web Analytics
  Windows Forms
  WPF
  WWF
  XML
  XSLT
All rights reserved to dotnetcodes. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks.
Best viewed at 1024 x 768 resolution with Internet Explorer 5.0 or Mozila Firefox 3.5 or Google Crome and higher