Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with this

Status
Not open for further replies.

tsisher

Programmer
Sep 14, 2004
36
GB
I have a web form where I call a method, if page is not post back some thing like
if (!IsPostBack)
FillCustomerDetails();

and FillCustomerDetails call a third party component and get a string back. I chop that string fill few asp:TextBox like

txtAddress.Text = obj.Address;
txtPostCode.Text = obj.PostCode;

etc...

Now I have a
<input type="text" name="getAddress" id="getAddresst" onkeyup="keyUp(event)" /> control on the same page.

So when user type in any thing in this Textbox, onkeyup is fired which is written in seperate .js file, which I have included on this page.

Now this javascript Function onkeyup calls the c# code as

document.getElementById('btnAddress').click(); (which is a <asp:Button>)

So javascript is basically calling c# code and c# code is setting the values on <asp:TextBoxex> like

txtAddress.Text = obj.Address;
txtPostCode.Text = obj.PostCode;

Now my problem is, first time when page is loaded , it checks !IsPostBack and fills the TextBoxes
txtAddress.Text = obj.Address;
txtPostCode.Text = obj.PostCode;

But when user types the new Address in the
<input type="text" name="getAddress" id="getAddresst" onkeyup="keyUp(event)" />,
javascript function fires , calls same c# code and fills the relevant text boxes again.

but when I do the view source it still shows the old values in the text boxex though when I debug it shows that new values are added.

What can I do to make these new values available to the browser?

Thanks

 
to be clear, javascript does not call C#. javascript sends a request to a url. how that url handles the request is completely independent of what's happening/happened on the client. the url code be static html, asp.net, classic asp, ruby, php, perl etc. this is one of the main factors with web development there is a distinct line between what happens on the client and what happens on the server.

when you call 'button.click' the browser sends a request to the server, the server processes the request and sends a response. the browser renders the response.

there is also the concept of AJAX (asynchronous javascript and xml). where only part of the screen is updated. the user experience is improved be the user doesn't need the entire screen to refresh to change a small portion of the page. the mechanics of AJAX are the same as a full page refresh. the difference is instead of the browser rendering an entire page, your javascript code can alter a subset of the page.

I doubt this will fix your immediate problem. Hopefully it will provide some insight into the infrastructure so you can better diagnose the problem.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top