Can you say whether it is possible to return html-formatted contents instead of just text to the autocomplete extender and have it display in the drop-down list? If not, another thought would be if dynamicpopulate can be triggered from typing in a text field
instead of clicking a control, and have it show a panel with contents reflecting that string.. Your thoughts?
You could monitor the key presses in the textbox and then call the populate() method on a dynamicpopulate control to reload every key press. You will need to set the context key of the dynamicpopulate to the value in the textbox before calling populate().
Hmm, I get the error "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)." on the line with "dp.set_ContextKey($get('<%=MyTextBox.ClientID%>').value);"
Yes, thanks - this solves the error. The problem is now - the control is triggered when I click in the textbox or type a letter, and remains like that, no matter what I type afterwards (hints.cs returns the result of a select * from table where name like
%contextKey%)
<head>
<script type="text/javascript">
function sAutoComplete()
{
var dp = $find('sHintsExtender');
dp.set_ContextKey($get('<%#sTextBox.ClientID%>').value);
dp.populate();
}
</script>
Helminthe
0 Points
3 Posts
HTML content in autocomplete/dynamicpopulate extender?
Oct 06, 2007 06:31 PM|LINK
Hi all,
Can you say whether it is possible to return html-formatted contents instead of just text to the autocomplete extender and have it display in the drop-down list? If not, another thought would be if dynamicpopulate can be triggered from typing in a text field instead of clicking a control, and have it show a panel with contents reflecting that string.. Your thoughts?
Jason Hill
Contributor
2019 Points
497 Posts
Re: HTML content in autocomplete/dynamicpopulate extender?
Oct 07, 2007 10:32 PM|LINK
You could monitor the key presses in the textbox and then call the populate() method on a dynamicpopulate control to reload every key press. You will need to set the context key of the dynamicpopulate to the value in the textbox before calling populate().
Something along the lines of:
<asp:TextBox id="MyTextBox" runat="server" onkeypress="MyFunction()"/>
and the JS:
MyFunction()
{
var dp = $find('MyDynamicPopulateControl');
dp.set_ContextKey($get('<%=MyTextBox.ClientID%>').value);
dp.populate();
}
Helminthe
0 Points
3 Posts
Re: HTML content in autocomplete/dynamicpopulate extender?
Oct 08, 2007 06:17 AM|LINK
Hmm, I get the error "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)." on the line with "dp.set_ContextKey($get('<%=MyTextBox.ClientID%>').value);"
[:(]
Jason Hill
Contributor
2019 Points
497 Posts
Re: HTML content in autocomplete/dynamicpopulate extender?
Oct 08, 2007 06:24 AM|LINK
Try using #MyTextBox.ClientID instead of =MyTextBox.ClientID.
Helminthe
0 Points
3 Posts
Re: HTML content in autocomplete/dynamicpopulate extender?
Oct 08, 2007 08:46 AM|LINK
Yes, thanks - this solves the error. The problem is now - the control is triggered when I click in the textbox or type a letter, and remains like that, no matter what I type afterwards (hints.cs returns the result of a select * from table where name like %contextKey%)
<head>
<script type="text/javascript">
function sAutoComplete()
{
var dp = $find('sHintsExtender');
dp.set_ContextKey($get('<%#sTextBox.ClientID%>').value);
dp.populate();
}
</script>
</head>
<asp:Panel ID="sHintsPanel" runat="server" />
<ajt:DynamicPopulateExtender ID="sHintsExtender" runat="server" TargetControlID="sHintsPanel" ServicePath="/hints.asmx" ServiceMethod="showhints" PopulateTriggerControlID="sTextBox" ClearContentsDuringUpdate="true" />
<asp:TextBox id="sTextBox" runat="server" onkeypress="sAutoComplete()"/>
Jason Hill
Contributor
2019 Points
497 Posts
Re: HTML content in autocomplete/dynamicpopulate extender?
Oct 08, 2007 10:04 AM|LINK
Not sure I fully understand the problem now...are you saying that the panel is being populated correctly or not on key presses.
You will need to then have some JS that handles the selection of the value from your HTML content and then places a value back into the textbox.