update drop down as soon as hitting add button on another form
here is the scenario:
I have drop down box on webform1.aspx and a link to bring up webform2.
on webform2, there is "add" button and text box which could add a new entry , how can I after click add button on webform2, the drop down list on webform1 gets updated as well.
so user doesn't need to hit refresh to see the changes
Re: update drop down as soon as hitting add button on another form
Assuming you open the second window using "window.open", you can reference client side controls on the original document by using window.opener (assuming I remember correctly).
However, one notes that by modifying the control's content on the client side, one will invalidate the control's viewstate and one will not be able to access the list item contents on postback (e.g. dropDownList.Items); one will have to use the posted back values available in Request.Form.
Re: update drop down as soon as hitting add button on another form
This is all done using Javascript.
You need a JS function in your WebForm1 page that will add values to a listbox
And you need to add JS to the OnClick event of your add button, which calls the JS function on WebForm1 and passes the values you want adding.
Or, have all the JS on the OnClick on the add button that adds the data to the webform1's controls. I prefer the 1st method myself, as it keeps all the code relating to controls in the same page.
I don't know this code off the top of my head, but I can post it on Monday when I get to work.
Woka
Re: update drop down as soon as hitting add button on another form
That's what I'm looking for too !
How did you (redshirtme) solved this ?
Otherwise, could Wokawidget (or someone) else tell me please ?
Thx !
Re: update drop down as soon as hitting add button on another form
OK...Say you have WebForm1 and WebForm2.
WebForm2 is the "child" form, that is opened when some action on WebForm1 is done by the user.
In Web form1 you need the following JS:
Code:
<SCRIPT language="javascript">
function OpenPopUp(SomeParam)
{
var sFeatures = ''
sFeatures=''
sFeatures+='top=100,'
sFeatures+='left=200,'
sFeatures+='height=500px,'
sFeatures+='width=400px,'
sFeatures+='scrollbars=no,status=no,toolbar=no'
window.open('WebForm2.aspx?ParamName='+SomeParam,'My Popup',sFeatures)
}
function CallBackFunction(SomeData)
{
'random code here that makes webform1 update
}
</SCRIPT>
Then in Page load you do the following:
VB Code:
Me.btnDoSomething.Attributes.Add("onclick", "OpenPopupWindow(" & _SomeParam.ToString & ");return false;")
This means that when clicking on the button it runs the JS that we added to WebForm1 and opens up the popup.
Now...in WebForm2 page load:
VB Code:
Me.btnDoSomething.Attributes.Add("onclick", "Javascript:window.opener.CallBackFunction(" & _SomeParam.ToString & ");return false;")
Now when you click this it calls the call back JS on the WebForm1.
Anyways. gotta go to a meeting. Will post more tmrw.
Woooof