Showing posts with label auto. Show all posts
Showing posts with label auto. Show all posts

Monday, March 26, 2012

Ajax Auto Sugest problem with LTR languages

Hi,I Use Ajax auto suggest text box. this autosuggest text box lookup throw table string field(nvarchar).It works find for Numbers and English words. But When I use LTR languages like arabic,the textbox does not show anything at all. I use UTF-8 and when I search this field it leads to correct results

but I don't know what is the problem with it.

Best regards,

Hi,

According to your description, it seems that ado.net fail to get data when use LTR languages.

I suspect this is a question regarding database. Please ask in this queue: http://forums.asp.net/54.aspx

Ajax Auto Postback I think needed

Alright I am attempting to make a site to do ping tests and I would like to make it look as realistic as the command prompt as possible. That is as far as having one result returned at a time.

currently it returns all of the pings responses all at once instead of one at a time. you can check out the code in working order at http://tools.shotdrive.com

here is my code behind page code

protected void DNSCheck_btn_Click(object sender, EventArgs e)
{
Timer1.Enabled = true;
}

protected void pingfunction()
{
try
{
//
switch (PingStatus)
{
case "Success":

lblStatus.Text += "Reply from: " + Convert.ToString(pingreply.Address) + " \r";
lblStatus.Text += "Bytes: " + Convert.ToString(pingreply.Buffer.Length.ToString()) + " \r ";
lblStatus.Text += "Time: " + Convert.ToString(pingreply.RoundtripTime) + " \r";
lblStatus.Text += "TTL: " + Convert.ToString(pingreply.Options.Ttl) + " \r <br>";

//ResponseText += "Reply from: " + Convert.ToString(pingreply.Address) + " \r";
//ResponseText += "Bytes: " + Convert.ToString(pingreply.Buffer.Length.ToString()) + " \r ";
//ResponseText += "Time: " + Convert.ToString(pingreply.RoundtripTime) + " \r";
//ResponseText += "TTL: " + Convert.ToString(pingreply.Options.Ttl) + " \r <br>";
break;

case "TimedOut":
lblStatus.Text += "Request timed out.<br>";

//lblStatus.DataBind();
break;

case "DestinationHostUnreachable":
lblStatus.Text += "Destination Host Unreachable<br>";
//lblStatus.DataBind();
break;

case "DestinationUnreachable":
lblStatus.Text += "Ping request could not find host r.red.com. Please check the name and try again.<br>";
//lblStatus.DataBind();
break;
case "BadDestination":
lblStatus.Text += "Ping request could not find host r.red.com. Please check the name and try again.<br>";
//lblStatus.DataBind();
break;

case "BadRoute":
lblStatus.Text += "Ping request could not find host " + txtHost.Text.Trim() + " Please check the name and try again <br>";
//lblStatus.DataBind();
break;

default:
lblStatus.Text = "SOME Error";
break;

}

}
catch (Exception err)
{

lblStatus.Text += "Ping request could not find host " + txtHost.Text.Trim() + " Please check the name and try again <br>";

}
}
protected void Timer1_Tick(object sender, EventArgs e)
{

lblStatus.Text = null;

for (int q = 0; q < Convert.ToInt32(tb_PingCount.Text); q++)
{
String host = txtHost.Text.Trim();
pingreply = ping.Send(host);
PingStatus = pingreply.Status.ToString();
pingfunction();

}
}

and my aspx page code

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<div style="left: 134px; width: 895px; position: relative; top: 0px; height: 502px">

<asp:Button ID="DNSCheck_btn" runat="server" OnClick="DNSCheck_btn_Click" Style="left: 313px;
position: relative; top: -1px" Text="Submit" /><asp:TextBox ID="txtHost" runat="server" Style="left: -74px;
position: relative; top: -3px"></asp:TextBox><asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server" ControlToValidate="tb_PingCount"
ErrorMessage="Invalid Input" Style="left: 16px; position: relative; top: -4px"
ValidationExpression="^(.?\d*)$"></asp:RegularExpressionValidator><asp:TextBox ID="tb_PingCount" runat="server"
Style="left: -131px; position: relative; top: -2px" Width="39px">1</asp:TextBox><br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Enabled="False" Interval="5000" OnTick="Timer1_Tick">
</asp:Timer>

<div style="left: 0px; width: 417px; position: relative; top: 0px; height: 42px">
</div>

<asp:Label ID="lblStatus" runat="server" Height="185px"
Style="left: -14px; position: relative; top: 4px" Width="391px"></asp:Label>
<asp:Label ID="lbltest" runat="server" Style="left: 68px; position: relative; top: -12px"
Width="169px"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DNSCheck_btn" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<br />
</div>

</div>
</form>
</body>
</html>

Any Help on this would be greatly appreciated

Some logical chage to your code can do that for you!

1. Add a hidden field. Add following line within update panll contenttemplate

<asp:HiddenField runat=server ID="counter" />

2.Add folloing lines in DNSCheck_btn_Click function

counter.Value = tb_PingCount.Text;
lblStatus.Text = "";

3.Modify Timer1_Tick as follows

protected void Timer1_Tick(object sender, EventArgs e)
{

// lblStatus.Text = null;

//for (int q = 0; q < Convert.ToInt32(tb_PingCount.Text); q++)
//{
String host = txtHost.Text.Trim();
pingreply = ping.Send(host);
PingStatus = pingreply.Status.ToString();
pingfunction();
int count=Convert.ToInt32(counter.Value);
count=count-1;
counter.Value = count.ToString();
if (count == 0)
Timer1.Enabled = false;
//}
}

This should work. I hope you understood the logic.


Thank you that worked perfectly

AJAX Auto Complete with sql look-up

Ok he's the thing,

I have the following auto complete on a aspx page for a seach function, im wanting it to look-up the names using the sql on line 20

1<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">2 <Services>3 <asp:ServiceReference Path="AutoComplete.asmx" />4 </Services>5 </ajaxToolkit:ToolkitScriptManager>6 <h1>7 Search Page</h1>8 <table>9 <tr>10 <td>11 <asp:TextBox ID="searchTextBox" runat="server"></asp:TextBox></td>12 <td style="width: 100px">13 <asp:Button ID="searchButton" runat="server" Text="Search" /></td>14 </tr>15 </table>16 <ajaxToolkit:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="searchTextBox"17 ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="2"18 CompletionInterval="1000" EnableCaching="true" CompletionSetCount="12">19 </ajaxToolkit:AutoCompleteExtender>20 <asp:SqlDataSource ID="autoCompleteSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:autoCompleteConnectionString%>" SelectCommand="SELECT [fishName] FROM [tblFishTypes]"></asp:SqlDataSource>

Then i've the following code in the asmx file...

1Imports System.Web2Imports System.Web.Services3Imports System.Web.Services.Protocols4Imports System.Collections.Generic56<WebService(Namespace:="http://tempuri.org/")> _7<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _8<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _9<System.Web.Script.Services.ScriptService()> _10Public Class AutoComplete11 Inherits System.Web.Services.WebService1213 <WebMethod()> _14 Public Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As String()15 Dim c1 As Char16 Dim c2 As Char17 Dim c3 As Char1819 If (count = 0) Then20 count = 1021 End If2223 Dim rnd As New Random()2425 Dim items As New List(Of String)2627 For i As Integer = 1 To count2829 c1 = CStr(rnd.Next(65, 90))30 c2 = CStr(rnd.Next(97, 122))31 c3 = CStr(rnd.Next(97, 122))3233 items.Add(prefixText + c1 + c2 + c3)34 Next i3536 Return items.ToArray()37 End Function3839End Class

Now i know i need to swap out the lines 23-33 and point instead to my sql connection string... right? but how? The random chaaters work but i want to limit the autocomplete to my database
Thanks Dooie

The data source declared on the ASPX page is out of the scope on the web service. Create a SQL Data Reader and create an array of fish names from within the method.


Nope sorry, im still lost, could explain a little further?


Hi,

You can replace them by creating a SqlDataAdapter to fetch data from database.

Hereis an example of using SqlDataAdapter.

Ajax Auto Complete Text Box

hi experts,

i am using the Ajax Auto Complete, i have used in the same way the Ajax Tool Kit has. The auto complete values are coming fine but the drop down window is transparent and i can see the control behind that. even the style sheet i have used the same way the example has but icant figure out what is the problem.

another problem is when i click enter in the text box(which is enabled for auto complete) i am getting an run time error 'this.postbacksettings.async' is null or not an object.

can any one help on this.

Thank you.

I had to double check. I do not have specific CSS attached to my AutoComplete. Are you using CSS friendly adapters? If you can post your text box, auto complete and snip it of CSS that would help.


hi,

i have followed this site,

http://asp.net/AJAX/Control-Toolkit/Live/AutoComplete/AutoComplete.aspx

and done the same way it has been said and downloaded the web application and used the css also whihc is given in this application. the CSS is

/*AutoComplete flyout */

.autocomplete_completionListElement
{
visibility :hidden;
margin :0px!important;
background-color :inherit;
color :windowtext;
border :buttonshadow;
border-width :1px;
border-style :solid;
cursor :'default';
overflow :auto;
height :100px;
text-align :left;
list-style-type :none;
}

/* AutoComplete highlighted item */

.autocomplete_highlightedListItem
{
background-color:#ffff99;
color:black;
padding:1px;
}

/* AutoComplete item */

.autocomplete_listItem
{
background-color :window;
color :windowtext;
padding :1px;
}

/*trial for the test*/

.ContextMenuPanel
{
border:1pxsolid#868686;
z-index:1000;
background:url(images/menu-bg.gif)repeat-y00#FAFAFA;
cursor:default;
padding:1px1px0px1px;
font-size:11px;
}

.ContextMenuBreak
{
margin:1px1px1px32px;
padding:0;
height:1px;
overflow:hidden;
display:block;
border-top:1pxsolid#C5C5C5;
}

a.ContextMenuItem
{
margin:1px01px0;
display:block;
color:#003399;
text-decoration:none;
cursor:pointer;
padding:4px19px4px33px;
white-space:nowrap;
}

a.ContextMenuItem-Selected
{
font-weight:bold;
}

a.ContextMenuItem:hover
{
background-color:#FFE6A0;
color:#003399;
border:1pxsolid#D2B47A;
padding:3px18px3px32px;
}

/*trial for the test*/

the code is

<AjaxToolkit:AutoCompleteExtender
runat="server"
BehaviorID="AutoCompleteEx"
id="autocomplete1"
targetcontrolid="txtAnswerDesc"
minimumprefixlength="1"
servicemethod="GetCompletionList"
servicepath="../Helpinfo.asmx"
CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="5"
CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
>
<Animations>
<OnShow>
<Sequence>
<%-- Make the completion list transparent and then show it --%>
<OpacityAction Opacity="0" />
<HideAction Visible="true" />

<%--Cache the original size of the completion list the first time
the animation is played and then set it to zero --%>
<ScriptAction Script="
// Cache the size and setup the initial size
var behavior = $find('AutoCompleteEx');
if (!behavior._height) {
var target = behavior.get_completionList();
behavior._height = target.offsetHeight - 2;
target.style.height = '0px';
}" />

<%-- Expand from 0px to the appropriate size while fading in --%>
<Parallel Duration=".4">
<FadeIn />
<Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteEx')._height" />
</Parallel>
</Sequence>
</OnShow>
<OnHide>
<%-- Collapse down to 0px and fade out --%>
<Parallel Duration=".4">
<FadeOut />
<Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx')._height" EndValue="0" />
</Parallel>
</OnHide>
</Animations>
</ajaxtoolkit:autocompleteextender>

Anything else if you need let me know.

thank you.


I haven't had a chance to completely review this, however, on a quick look check out the background-color for both the ".autocomplete_completionListElement" and ".autocomplete_listItem" classes. The inherited and window options may be playing havoc especially if the browsers background color is set to transparant. Have you tried specifying a color in both of those classes?


thanks for your reply.

i have tried changing the background color and still i am seeing the controls behing the list item.

please help me to solve this.


Have you tried adding a div as target for autocomplete?

<divID="divAutoComp"></div>

And in:

<ajaxToolkit:AutoCompleteExtenderCompletionListElementID="divAutoComp" etc..>

Then you could "manually" style the div...


hi,

thanks for your reply. i am having a form->table->text box and outside that table i am having the AutoCompleteExtender. can you explain me where i should use the DIV and for target what control i have to give.

waiting for your reply!!!!


- Place the div whereever you want the suggestions to appear.

-<ajaxToolkit:AutoCompleteExtenderrunat="server"ID="ACE1"

MinimumPrefixLength="2"CompletionSetCount="1"CompletionInterval="1"

TargetControlID="userTB"EnableCaching="false"CompletionListElementID="divAutoComp"

ServiceMethod="GetMail">

**TargetControlIDis the textbox you want autocomplete to work on.

**CompletionListElementID is the div where you want the suggestions to appear.

(**CompletionSetCount is the number of suggestions you want to see)


NNM:

**CompletionListElementID is the div where you want the suggestions to appear.

I didn't need to specify a CompletionListElementID, however that is a good tip. I can all ready see a good use for that!. Thanks, NNM.


k2schreck:

NNM:

**CompletionListElementID is the div where you want the suggestions to appear.

I didn't need to specify a CompletionListElementID, however that is a good tip. I can all ready see a good use for that!. Thanks, NNM.

but for my code it doesnt make much difference. it still works the same way as it was working before giving the CompletionListElementID .


sbadriprasad:

but for my code it doesnt make much difference. it still works the same way as it was working before giving the CompletionListElementID .

Do you use multiple css files? If so exclude one at a time and test to see if it works. That will help narrow down a css culprit. I have not caputred the return html from the AutoComplete so I don't know if it uses a div, table, ul etc. but examine closely any generic tags in your css file. One of them may be causing the troubles.

Gook luck!

Ajax auto complete extender

I am using ajax autocompleteextender. I have declared the service method in the user control itself instead of declaring it in aspx page. But the extender does not work .How can i do it? I want to declare it in ascx page,as i will be reusing the component.

my master page script
=====================
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true"/asp:ScriptManager
my aspx page where i am inheriting masterpage
==============================================

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="frmTestAuto.aspx.cs" Inherits="frmTestAuto" Title="Untitled Page" %>
<%@. Register src="http://pics.10026.com/?src=ctlAutoExtender.ascx" TagName="ctlAutoExtender" TagPrefix="uc1" %>
<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" /asp:ScriptManagerProxy>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>TEST AUTO PAGE</td>
</tr>
<tr>
<td>uc1:ctlAutoExtender ID="CtlAutoExtender1" runat="server" /</td>
</tr>
<tr>
<td>Footer</td>
</tr>
</table>
</asp:Content
my ascx page
=============
<%@. Control Language="C#" AutoEventWireup="true" CodeFile="ctlAutoExtender.ascx.cs" Inherits="ctlAutoExtender" %>
<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"></asp:ScriptManagerProxy>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<asp:TextBox runat="server" ID="myTextBox" Width="300" />

<ajaxToolkit:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="myTextBox" Enabled="true"
ServiceMethod="GetCompletionList" ServicePath="ctlAutoExtender.ascx.cs" MinimumPrefixLength="3"
CompletionInterval="1000" EnableCaching="true"
CompletionSetCount="12"/>
</td>
</tr>
</table
my ascx.cs page
===============

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Web.Services;
using System.Web.Script.Services;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]

public partial class ctlAutoExtender : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{

}

[WebMethod]
[ScriptMethod]
public static string[] GetCompletionList(string prefixText, int count)
{
string sql = String.Format("select clt_tVLongNm from mclient where clt_tVLongNm like @.companyname + '%'");

List<string> companyList = new List<string>();

using (SqlConnection connection = new SqlConnection("server=192.168.2.57;uid=sa;pwd=d28rg6yp;database=fnocash_report"))

using (SqlCommand command = new SqlCommand(sql, connection))
{
connection.Open();
command.Parameters.AddWithValue("@.companyname", prefixText);
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
companyList.Add(reader.GetString(0));
}
}
}
return companyList.ToArray();
}
}

please help me out asap


Hi,

In ASP.NET, a request for a .ascx file will be?handled?by?System.Web.HttpForbiddenHandler?HttpHandler,?that's?to?say,?it's?refused.
So you can't use a method in the UserControl, I suggest trying to use a web service(.asmx) to achieve this.
Hope this helps.

Hi,

I am declaring the autocompleteextender in the user control. So, should I give service path for the extender as .asmx file in the extender?

eg:

My ascx page:

<%

@.ControlLanguage="C#"AutoEventWireup="true"CodeFile="ctlAutoExtender.ascx.cs"Inherits="ctlAutoExtender" %>

<%

@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<

tablecellpadding="0"cellspacing="0"border="0"width="100%"><tr><td><asp:TextBoxrunat="server"ID="myTextBox"Width="300"/>

<ajaxToolkit:AutoCompleteExtenderrunat="server"ID="autoComplete1"TargetControlID="myTextBox"Enabled="true"ServiceMethod="GetCompletionList"ServicePath="App_Code/WebService.cs"MinimumPrefixLength="3"CompletionInterval="1000"EnableCaching="true"CompletionSetCount="12"/></td></tr>

</

table>


Yes,?like?this:??ServicePath="the relative path of the .asmx file"
Thanks, that solved my problem.