|
I was not very sure where to post this. Found aspx and httphandler related to asp.net so posted here.
I have used JQuery to call autocomplete on a textbox1 as below:
$("input#textbox1").autocomplete({
source: ["India", "Japan", "United Kingdom", "United States", "Australia", "France", "China"]
});
This works fine.
When i try to change this to
$("input#textbox1").autocomplete('GenericHandler.ashx');
, the 'GenericHandler.ashx' never gets called.
In ProcessRequest method of GenericHandler, i have written
context.Response.Write("India|Japan|United Kingdom|United States|Australia|France|China");
I have included appropriate verb in web.config for caller.
How do i achieve the autocomplete calling ashx and then getting data to fill ?
Please help.
note: I am using jquery-ui.min.js for AutoComplete.
|
|
|
|
|
hi RaviSant,
As far as i know,
u can use JSON format to return ur result from ashx file.
and in the .autocomplete use options as parameter.
like this.
var options, a;
jQuery(function(){
options = { serviceUrl:'GenericHandler.ashx' };
a = $('#query').autocomplete(options);
});
and in the web service class, return the JSON format like this.
{
query:'Li',
suggestions:['India', 'Japan', 'United Kingdom', 'United States', 'Australia', 'France', 'China'],
data:['IN','JP','UK','US','AZ','FR','CH']
}
query is the entered search key
suggestions is the list to display in dropdown
data is optional to use as value field when u select suggestion data from dropdown text
To know more about JSON,here[^]
To learn how to return JSON format from ashx , here[^]
Ref: I get this code from devbridge.com[^]
Hope this works!
Please give any idea or suggestion on my advice.
|
|
|
|
|
First, the company prefers classic asp rather than asp.net. So, apologies to the .net gurus out there.
I've tried isolating various parts of this code and can't figure out why this returns the first record multiple times. Like, it's not moving to the next record in the recordset.
Dim ID2, RefDoc, RefRev, RefNotes, strSQL3
Set objCon = Server.CreateObject ("ADODB.Connection")
Set objRec = Server.CreateObject ("ADODB.Recordset")
strSQL3 = "SELECT * FROM UMIDRefDocs WHERE CardNo ='" & CardNo & "'"
objCon.Open strCon
objRec.Open strSQL3, objCon
If objRec.EOF = true then
Response.Write("<tr><td colspan=3>No reference documents exist for this card.</td></tr>")
End If
If Not objRec.EOF and not objRec.BOF then
ID2 = objRec("ID")
RefDoc = objRec("RefDoc")
RefRev = objRec("RefRev")
RefNotes = objRec("RefNotes")
Do Until objRec.EOF
Response.Write("<tr><td><a href='do_UMID_EditRefDocs.asp?RefDoc=" & RefDoc & "&Action=Delete&CardNo=" & CardNo & "'><img src='images/delete.gif' alt='Delete' border='0'></a>")
Response.Write("  <a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>  " & RefDoc & " </td>")
Response.Write("<td>" & RefRev & " </td>")
Response.Write("<td>" & RefNotes & " </td></tr>")
objRec.MoveNext
Loop
End If
objRec.Close
objCon.Close
Set objRec = Nothing
Set objCon = Nothing
I've used this same pattern in other pages: Define the SQL string, open the recordset, write the table row for the current record, MoveNext, Loop, close the connection. But this time, for the given recordset I'm looking at, there are two records; I only get the first one repeated twice.
Any ideas?
----------------------------------
I'm not a programmer by trade, so please don't beat me unmerciful.
|
|
|
|
|
Bomb_shell wrote: ID2 = objRec("ID") RefDoc = objRec("RefDoc") RefRev = objRec("RefRev") RefNotes = objRec("RefNotes")
These statemens are outside your loop, no wonder you see the same data over and over.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
hi Bomb_shell,
As far as i know, in your problem, u assign the variable with first record and
never assign it again when u loop and print out.
So, as a suggestion, I re-order ur code.
(I don't know much about VB )
If objRec.EOF = true then
Response.Write("<tr><td colspan=3>No reference documents exist for this card.</td></tr>")
Else
Do Until objRec.EOF
ID2 = objRec("ID")
RefDoc = objRec("RefDoc")
RefRev = objRec("RefRev")
RefNotes = objRec("RefNotes")
Response.Write("<tr><td><a href='do_UMID_EditRefDocs.asp?RefDoc=" & RefDoc & "&Action=Delete&CardNo=" & CardNo & "'><img src='images/delete.gif' alt='Delete' border='0'></a>")
Response.Write("  <a href='UMID_RefDocs.asp?CardNo=" & CardNo & "&RefDoc=" & RefDoc & "&Action=Edit'><img src='images/edit.gif' alt='Edit' border='0'></a>  " & RefDoc & " </td>")
Response.Write("<td>" & RefRev & " </td>")
Response.Write("<td>" & RefNotes & " </td></tr>")
objRec.MoveNext
Loop
End If
Hope it works!
|
|
|
|
|
its simple. it doesn't move because it is outside the loop.
it should
Do Until objRec.EOF
ID2 = objRec!ID
objRec.MoveNext
Loop
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
wow.. people still do plain asp/vbs?
|
|
|
|
|
Thanks, y'all. That was so dumb, I didn't even think of that. But it worked and I'm good now.
HaBiX wrote: wow.. people still do plain asp/vbs?
It's a company limitation, but I'm a noob, so I don't mind learning it old school before I learn the "real" way.
----------------------------------
I'm not a programmer by trade, so please don't beat me unmerciful.
|
|
|
|
|
Hi all,
I am new to AJAX. I have one ajax tab container and two tabs in it. In each tab I have gridview to show the data. The colums are same in both of the gridviews. So I was wondering whelther we can use just one gridview and use in both tabs like reusuable grid view. But I don't know how to do that. CCan anyone please refer me to the links having those kinds of examples ?
Thanks in advance,
suchita
|
|
|
|
|
Sir;
I don't think that you need a tab container, all you need is two spans with the attribute onclick set to GetPostbackEventReference() (or any thing can cause potback) , a div, and an update panel cotaning the grid.
so you can update the grid content every postback.
Good Louk
Help people,so poeple can help you.
|
|
|
|
|
Actually I need to show in the tab forms.. So I have multiple tabs in that page.
suchita
|
|
|
|
|
TabContainer is rendered somthing like
<span>Tab1</span>
<span>Tab2</span>
<div>Div1</div>
<div>Div2</div>
when you click a span (or tab header) the display of the assosiated div (tab body) is toggled to block and the other to none.
what i want you to do is drawing something that looks like a tab container with one div and no display toggling just like
<span>Tab1</span>
<span>Tab2</span>
<div>Div1
<asp:updatepanel ID="updatepanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" />
</ContentTemplate>
</ asp:updatepanel>
</div>
you can also use a tab container, but you will need to add the grid dynamically in the code (server side).
100
Help people,so poeple can help you.
|
|
|
|
|
HI all,
I am creating a webapplication in c#.net.In this apllication i am displaying files from the server.
Now what i want to do is , i want to download the selected file.
How can i do this ?
Thanks in advance.
|
|
|
|
|
This may help you. May be you need to tweak the code little bit. Give a try
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
namespace photoshops
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
onflbload(sender, e);
}
public void onflbload(object sender, EventArgs e)
{
int len = flbload.PostedFile.ContentLength;
byte[] pic = new byte[len];
flbload.PostedFile.InputStream.Read(pic, 0, len);
SqlConnection connection = new SqlConnection(@"Data Source=DEVI\SQLEXPRESS;
Initial Catalog =cat; Integrated Security=SSPI");
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=DEVI\SQLEXPRESS; Initial Catalog =cat; Integrated Security=SSPI";
try
{
connection.Open();
SqlCommand cmd = new SqlCommand("insert into tblphotosettings " + "(BillNo,CustomerName,Address,StartDate,EndDate,Numberofcopies,) values (@BillNo,@CustomerName,@Address,@StartDate,@EndDate,@Numberofcopies,)", connection);
cmd.Parameters.Add("@BillNo", SqlDbType.NVarChar).Value = TextBox1.Text;
cmd.Parameters.Add("@CustomerName", SqlDbType.NVarChar).Value =TextBox2.Text;
cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = TextBox3.Text;
cmd.Parameters.Add("@StartDate", SqlDbType.NVarChar).Value =Rdbsdate.SelectedDate;
cmd.Parameters.Add("@EndDate", SqlDbType.NVarChar).Value =Rdbddate.SelectedDate;
cmd.Parameters.Add("@Numberofcopies", SqlDbType.NVarChar).Value =TextBox7.Text;
cmd.CommandText = "photosets";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.Add("@Systemurl", SqlDbType.Image).Value = pic;
SqlParameter Src = new SqlParameter("@FilePath", SqlDbType.VarChar, 450);
cmd.Parameters.Add("@Amount", SqlDbType.NVarChar).Value = TextBox8.Text;
cmd.Parameters.Add("@Total", SqlDbType.NVarChar).Value = TextBox9.Text;
cmd.Parameters.Add(Src);
con.Open();
cmd.ExecuteNonQuery();
}
finally
{
connection.Close();
}
}
}
}
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[photosets]
(
@Systemurl image,
@Filepath varchar,
@Amount NVarchar,
@Total NVarchar
)
AS
BEGIN
insert into tblphotosettings
(
Systemurl,
Filepath,
Amount,
Total
)
values
(
@Systemurl,
@Filepath,
@Amount,
@Total
)
END Procedure or function photosets has too many arguments specified.and then i need store to image and image path name and record
|
|
|
|
|
You're adding to your parameters in the following lines:
cmd.CommandText = "photosets";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.Add("@Systemurl", SqlDbType.Image).Value = pic;
SqlParameter Src = new SqlParameter("@FilePath", SqlDbType.VarChar, 450);
cmd.Parameters.Add("@Amount", SqlDbType.NVarChar).Value = TextBox8.Text;
cmd.Parameters.Add("@Total", SqlDbType.NVarChar).Value = TextBox9.Text; The parameters collection has previously been assigned to by the command before it (even though you are changing the command you are issuing, you are still using the same command instance). Just before this, add the line
cmd.Parameters.Clear();
|
|
|
|
|
|
Hai Experts
I have done googlemap with single marker dynamically . i have tried same way for multiple marker where latitudes and longitudes comes from database .can u please suggest me How to approach.
Regards
venu
|
|
|
|
|
Venu,
I have used the control from subgurim to achieve what you are looking for. It works good. Have a look at it. Here is the
link
Thanks
|
|
|
|
|
Will you please post some code on how to make a persistence by making a page like igoogle.Sorry for bad english.
|
|
|
|
|
Sure.
private void MakePersistenceLayer()
{
IUnityContainer accessor = Context.ApplicationInstance as IUnityContainer;
if (accessor == null)
throw new ArgumentNullException("IUnityContainer should not be null");
IPersist persist = accessor.Resolve<Persister>();
persist.MakePersistent();
} There, I've given you a head start here. I leave it to you to fill in the trivial bits.
|
|
|
|
|
Hello all,
I am having a problem while refreshing my parent window.
I have a webform and I am using a viewstate on this form. on the viewstate's 3rd activeform I have a table. In a row of this table when the radiobutton's value is equal to No(I am doing an autopostback here) a popup window opens. Here on the popup window I make user to select some items in the checkbox list and carry the data to a textbox in the parent form. Till here everything is fine.
My problem is I can not close the popup. What happens is;
I can successfully pass the data to my parent window, refresh it but the popup windows closes and it popups again.
I am trying to do it with this code;
Page.RegisterStartupScript("CLOSE", "<script language='javascript'>window.opener.document.forms(0).submit();self.close();</script>");
What I also tried;
ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.onunload = CloseWindow();");
Page.RegisterStartupScript("CLOSE", "<script language='javascript'>window.opener.location.reload();self.close();</script>");
Page.RegisterStartupScript("CLOSE", "<script language='javascript'>window.opener.location.href = window.opener.location.href;self.close();</script>");
Page.RegisterStartupScript("CLOSE", "<script language='javascript'>window.opener.history.go(0) = window.opener.location.href;self.close()</script>");
These three doesnt work the way I want. They either popup the popup again, or close the popup, reload the parent but then parent goes back to Viewstate's active viewindex 1 instead of staying in 3.
Any ideas how can I fix this? Thanks
|
|
|
|
|
Hi,
I have a table in database for messages and it has these fields:
MessageId / SenderId / Message / Date
I'd like to create a list of messages but only show the latest message from each user not listing whole messages just like how facebook shows messages.
Is there a way to get the exact result by a sql query or I have to first get all the data from the database then build the list I want?
Thank you
|
|
|
|
|
You can do this (at least partially) in the db. For example:
SELECT ...
SUBSTRING(m.Message,1, 80) AS PartialMessage,
...
FROM Messages m
WHERE m.MessageID IN (SELECT MAX(m2.MessageId)
FROM Messages m2
GROUP BY m2.SenderId)
The above (with typos corrected etc ) should fetch the latest messsages for each sender and bring only first 80 characters of the message.
In the example I'm relying on a fact that the MessageId field is constantly growing number so it will order the messages correctly. If this is not true then you would have to use the date field to get the latest messages.
|
|
|
|
|
Farhad Eft wrote: Is there a way to get the exact result by a sql query
Yes if you want sorted data then use 'order by' statement.
if you want some condition data then use 'where' condition.
No need to get all the data from database and then build list.
|
|
|
|
|