Searchable TextBox using window.showModalDialog

D

dan_williams

I'm trying to create a textbox control on an asp.net web page, that
after a user has typed some text into it, another pop-up window appears
with a dropdownlist populated with options related to the text the user
entered.

My initial attempt was to create a javascript function that executes on
the onblur event of my textbox. My javascript function is as follows:-

function fnClient() {
var tURL = "modGetClient.aspx?client=" + Form1.client.value;
var tSearch = window.showModalDialog(tURL);
Form1.tClientId.value = tSearch;
Form1.submit();
}

My modGetClient.aspx page simply executes the following SQL statement
and populates a dropdownlist with all the resulting records. Once the
user clicks on an OK button, a javascript function sets the
window.returnValue to the selected option and the window gets closed.

SELECT ClientId FROM Clients WHERE BusinessName LIKE '%" +
Request("client") + "%' "

The tClientId is a hidden textbox value and I have server-side Sub
tClientId_TextChanged that i need to fire when it gets set by my
client-side fnClient function.
The tClientId_TextChanged function basically populates other form
fields based on the clientId selected from the modalDialog box.
However, it only seems to fire after i actually physically type
something in the hidden field (i made it a text type to test it).
Therefore, i added the Form1.submit() function to force a postback, but
this causes my validation controls to fire, which i don't want.

Can anyone recommend a way of doing this? Am i going down the right
route with a showModalDialog box? Is it possible to prevent page
validation from happening? Is it possible to call a server-side
function from client-side javascript?

Please help!!!

Dan
 
D

dan_williams

DOH!

It's OK, i managed to work it out for myself. Instead of performing the
Form1.submit(); i use __doPostBack('tClientId_TextChanged', '');

Seems to work exactly as i require

Thanks anyway

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top