|
Good Day All
i have a Function e.g
public String Getdata(String mystr)
{
}
and i want to call this function and pass data in Javascript like this
function KeyPress() {
var TExtbox1 = document.getElementById('Text1');
if (TExtbox1.value.length == 2) {
return false;
}
}
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
|
Thanks , Now i have this
On the Server side
[WebMethod, System.Web.Script.Services.ScriptMethod]
public static string Getadata(String Data)
{
String Scriptt = "<script>alert('" + Data + "');</script>";
return Scriptt;
}
function KeyPress() {
var TExtbox1 = document.getElementById('Text1');
var Results;
if (TExtbox1.value.length == 2)
{
Results = Getadata(TExtbox1.value);
alert(Results);
}
return false;
}
and my ScriptManager
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
</asp:ScriptManager>
but when i run it nothing happens
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
You call Getadata in your javascript. You should call PageMethods.Getadata instead.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks , sorry i missed that, now i have a small problem with my javascript
<br />
function KeyPress() {<br />
<br />
<br />
var TExtbox1 = document.getElementById('Text1');<br />
var Results;<br />
if (TExtbox1.value.length == 2) {<br />
<br />
Results = PageMethods.Getadata(TExtbox1.value);<br />
alert(Results);<br />
} <br />
return false;<br />
}<br />
the alert shows me "undefined"
is there anything wrong there ?
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
That's because a script method doesn't return like this. What you need to do is supply a callback function which your javascript executes. Here's a sample page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
<script>
function keyPress()
{
var tb = document.getElementById('Text1');
if (tb.value.length == 2)
PageMethods.Getadata(tb.value, myFunction);
return false;
}
function myFunction(msg)
{
alert(msg);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True" />
<div>
<input type="text" id="Text1" onkeypress="keyPress()" />
</div>
</form>
</body>
</html>
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Good Morning Pete
Thank you for your kind reples. its working like wonders. I have one last question. as you have seen i have been using a html textbox not an asp.net textbox. i see the asp text does not have the Keypress event , Is there a way that i can modify this working code to work with asp.net textbox defined like this
<asp:TextBox ID="Text2" runat="server"></asp:TextBox>
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Thanks for your help , i found the solution to my last request.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi,
I need to insert a logo image in banner bitmap property while creating a setup. But from the property i couldn't find the bannerbitmap property. Can you pls help me.....
Thanks.
krishna
|
|
|
|
|
win form setup creation???? you meen wix setup or you are writing your own ?!?!? there are definalty missing information. in wix you can set the banner image using the old one by just renaming the file
|
|
|
|
|
Do you mean in a Setup project in Visual Studio?
If so, right-click the Project and select View | User Interface (or us the menu View |Editor | User Interface)
In the properties of Install | Start | Welcome, "Banner Bitmap" is at the top. Just browse for what you want to use.
|
|
|
|
|
Hi,
This is most likely a basic problem but I can't get my head around it!
I am trying to construct a parameterized sql query that takes information entered from a textbox (the search box of the query) and adds it to the query before it executes.
What I would like to do is have the user search the 'CODE' column by entering something like:
= "CO" or "SO"
and have that added to my sql query after WHERE CODE
Any help greatly appreciated!
Joe
|
|
|
|
|
Erm. AFAIK the whole point of a parameterized query was to stop this kind of design so that's not going to work.
You'd have to go back to the old skool method of generating the entire SQL statement and firing it back to your DB. I'd check if you really need to as this is horrendously insecure. Can you just not create a search stored proc and pass in a search term on that?
|
|
|
|
|
Thanks,
I'll look at doing it through the stored procedure as you mentioned.
|
|
|
|
|
It depends on the type of database you are using as to how you tackle this, but you could add a temporary table that you use to add the individual parsed out elements in as individual elements, and then perform your main query using that table as a linked table, so you'd end up with SQL along the lines of:
SELECT ... FROM MyTable INNER JOIN MyTemporaryTable ON MyTable.Code = MyTemporaryTable.Code Also, rather than having them enter the codes, why not display them in a list that they can select from? This way you save them having to remember potentially archane code sequences.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Something like cmd.Parameters [ "@CodeVal" ].Value = tbCode.Text ; ?
|
|
|
|
|
|
Apart from being wide open to a SQL injection attack, this just won't work because it only applies to 1 value.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hello guys...
I am building a c# app to detect the internet connection and then send sms to a person regarding the status. I've got the codes with me but i wrote them as individual modules. I need to integrate them. any help????????? And by the way its a c# windows app...
|
|
|
|
|
S.Bharath Ram wrote: I've got the codes with me but i wrote them as individual modules.
What makes a difference if it is individual module or one single module, if the functionality of the application is as simple as you describe it.
S.Bharath Ram wrote: I need to integrate them.
integrate what? the difference modules? Well, if you know how to write the modules, you will know how to integrate them
|
|
|
|
|
Keep the question as brief as possible. Provide more information whatever you have written.
|
|
|
|
|
S.Bharath Ram wrote: individual modules. I need to integrate them
This is easy. The other way round is what most people struggle with.
|
|
|
|
|
5'd.
ragnaroknrol The Internet is For Porn[^]
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
+5 to correct the univote.
|
|
|
|
|
Edit : I have tried Dictionary<string[,], Texture2D> _lookup but doesnt work
In xna I want to create a texture2D factory class so that I can grab preloaded textures on the fly without having to load them repeatedly.
I want something like
paddleTexture = GetData<Texture2D>(string foldername,string assetname)
for example:
GetData<Texture2D>("Sprite","paddle");
But I am having generic Dictionary troubles
I just cant seem to create its structure properly !
I have tried Dictionary<string ,Dictionary<string,Texture2D>> which is not what I want at all and I also load the data via a simple XML file:
<?xml version="1.0" encoding="utf-8"?>
<FileSystem>
<Folder Name="Sprite" Location = "Image/2D/Sprite">
<Texture Name ="paddle"></Texture>
<Texture Name ="ball"></Texture>
</Folder>
</FileSystem>
Can anyone help me with the structure of the generic Dictionary?
Thanks !
-- Modified Wednesday, August 4, 2010 7:51 PM
|
|
|
|