|
Can you put alert(result); in your script to check the value?
Wout Louwers
|
|
|
|
|
Hi WoutL,
I already write it.In alert it displays True/False(depanding on
user name availability)
i am sending it as follow in my vb.net function.
dim isAvailable as boolean
then when i got response that user name is available or not if already in database then
isAvailable=0
response.Write(isAvailable)
then i caught response in result and watch it in alert(result);
when i saw response then it shows (True/False) depending on output
and it also shows HTML code on page.
I am sending my code with it.
My javascript as follow.
function OnChangedUsername()<br />
{<br />
if(document.Form1.newuserid.value == "")<br />
{<br />
}<br />
else<br />
{<br />
}<br />
}<br />
<br />
function OnCheckAvailability()<br />
{<br />
if(window.XMLHttpRequest)<br />
{<br />
oRequest = new XMLHttpRequest();<br />
}<br />
else if(window.ActiveXObject)<br />
{<br />
oRequest = new ActiveXObject("Microsoft.XMLHTTP");<br />
}<br />
<br />
oRequest.open("POST", "ProcessRequest.aspx", true);<br />
oRequest.onreadystatechange = UpdateCheckAvailability;<br />
<br />
oRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");<br />
<br />
oRequest.send("strCmd=availability&strUsername=" + document.Form1.newuserid.value);<br />
}<br />
<br />
function UpdateCheckAvailability()<br />
{<br />
if(oRequest.readyState == 4)<br />
{<br />
if(oRequest.status == 200)<br />
{<br />
var msg= new Boolean();<br />
alert(oRequest.responseText);<br />
var label=document.getElementById("lblMessage");<br />
if (oRequest.responseText=='False')<br />
{<br />
alert("not");<br />
label.innerHTML = 'NotAvailable';<br />
label.style.color='Red';<br />
}<br />
else if (oRequest.responseText=='True')<br />
{<br />
alert("available");<br />
label.innerHTML = 'Available';<br />
label.style.color='Green';<br />
}<br />
}<br />
else<br />
{<br />
document.getElementById("Result").innerHTML = "Asychronous Error";<br />
}<br />
}<br />
}<br />
This is my Server side Code of ProcessRequest Page.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
'Put user code to initialize the page here<br />
i = Request.Form("strUsername")<br />
'i = Request.QueryString("q")<br />
j = Request.Form("strCmd")<br />
'i = Request.QueryString("value")<br />
If i = Nothing Then<br />
Else<br />
IsUsernameAvailable(i)<br />
End If<br />
End Sub<br />
<br />
Public Function IsUsernameAvailable(ByVal Username As String) As Boolean<br />
Dim cn As SqlConnection<br />
Dim cmd As SqlCommand<br />
Dim dr As SqlDataReader<br />
'Dim isAvailable As Boolean<br />
Dim str As String<br />
Dim flg As Byte<br />
Try<br />
cn = New SqlConnection("connection string.")<br />
cn.Open()<br />
str = "select count(*) from CheckUser where UserName='" & i & "'"<br />
cmd = New SqlCommand(str, cn)<br />
flg = cmd.ExecuteScalar<br />
If flg = 1 Then<br />
isAvailable = 0<br />
Response.Write(isAvailable)<br />
'Response.Write("NotAvailable")<br />
'Response.End()<br />
Else<br />
'Response.Write("Available")<br />
isAvailable = 1<br />
Response.Write(isAvailable)<br />
'Return True<br />
'Response.End()<br />
End If<br />
Catch ex As Exception<br />
Response.Write(ex.Message + ex.StackTrace)<br />
Finally<br />
cn.Close()<br />
End Try<br />
End Function<br />
Rahul.
|
|
|
|
|
Try this:
<br />
var result = oRequest.responseText.toLowerCase();<br />
<br />
if(result == 'false')<br />
{<br />
...<br />
}<br />
else<br />
{<br />
...<br />
}<br />
Wout Louwers
|
|
|
|
|
Hi
Forum
I was looking for some advice for my applicaiton and best way to go about it.
I have defined users within a mysql database in a usersTable, and my asp deals with logging in and out of the system, but I obviously still need to make the asp connect to the database in a secure way, as at moment i have a simple connection string that is hardcoded into the system, i am sure there is a much more secure way of getting around this problem, any help would be much appreciated
many thanks
boy
|
|
|
|
|
I have a stand alone application (messenger). I was asked to the messenger to have the fallowing possibility:
from a link with a phone number parameter to make a call in the application. If the messenger is not installed, to take the client to the official web site. If the product is installed to see if it is open. If it is open and the user is logged in to make the call.
My idea is the client to check the registry and see if the product is there, which solves the first part. If there are certain keys in the registry next step is from the processes to see if the product is active. If active somehow send instruction to call the function : CallNumber( phonenumber phnum)
Can you give me any leads on how to do all this, any other solution to the task?
The project is done in C++
Thank you very much
Dimkov Trajce
|
|
|
|
|
you are posting in wrong section..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
To me the obvious solution is writing javaScript... but I am not sure of javaScript capabilities of reading from the registry.
This is why I put it on the web development forum
|
|
|
|
|
You wanna use javascript in your C++ standalone application??
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
No, the application is C++ standalone
but, my guess is if the link comes from a browser, the browser should handle the request, meaning, should do the described logic. The only thing the application is involved is calling it with the right parameter(phone number)if it is installed, if not, the web browser should go to the official website
|
|
|
|
|
Your original question was unclear. Javascript cannot access the registry (my computer does not have a registry), and is not very suitable for what you have in mind. Instead your only option is to register a new protocol in each browser, and have the browser itself start up your application. Skype does this with 'Skype me' links.
Details for how to do this in Firefox are here. You'll need to find something similar for IE.
|
|
|
|
|
it is possible to detect if the page has a horizontal
scrollbar using javascript ??
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
In IE:
if (document.body.clientHeight < document.body.scrollHeight)
{
alert("vertical scrolling");
}
if (document.body.clientWidth < document.body.scrollWidth) {
alert("horizontal scrolling");
}
in FX:
document.body.scrollTop+=10;
if (document.body.scrollTop==0) alert('no vertical scroll bar');
document.body.scrollLeft+=10;
if (document.body.scrollLeft==0) alert('no horizontal scroll bar');
|
|
|
|
|
thanks
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
I was wondering if anybody has a CSS script that will hide a button to go to the next page and will keep the button hidden until the user clicks on an pop-up ad. Please help.
|
|
|
|
|
you can do it using javascript.
For example:
document.getElementById("buttonId").onclick= function_name
function()
{
document.getElementById("buttonId").style.display= "block";
// or
document.getElementById("buttonId").style.visibility= "visible";
}
|
|
|
|
|
I have a dream, that some day, little black boys and white black girls with a java enabled telephone will be able to fire up a wap / web browser using PAN over bluetooth, thereby completely avoiding their wireless provider? ...
Does anyone know of any projects that promote connecting mobile devices (Java?)to bluetooth PANs?
Anyone interested in developing something like this contact me I have a dream, but nobody who can make heads or tails out of it
Have a nice day,
David - Ukraine
|
|
|
|
|
Hi all
Is there anyway in which i can set a double focus on page load. That when the page loads i can immediately begin typing into a textbox, but when i press enter that the correct button responds to the button press event. I would like this to happen thus the user doesn't need to click anywhere after the page load, but can merely type and hit enter. The pages are ASP2.0 forms by the way, and the textboxes and buttons asp buttons and textboxes. The code behind is in VB... Thanks for any help in advance..
Devin
|
|
|
|
|
In Textbox keypress event,
<br />
document.getElementById("SubmitButton").click();<br />
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Michael Sync wrote: document.getElementById("SubmitButton").click();
would cause the page to be submitted on EVERY keypress....not particularly useful
You need to check the char code for 13 (Enter) before submitting...
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman"
(Lilly Allen / Kaiser Chiefs)
|
|
|
|
|
If you using a server side script like: asp, jsp, php...etc, it can be done easly by storing the value of the visibility on the server.
If your page is a pure html page. I have no idea how it can be done.
|
|
|
|
|
Therein lies the problem. When the back button is used to navigate backwards inside an ASP.NET application none of the code is executed. This is because the page is loaded from local cache instead of grabbing a fresh copy from the server. Using values stored on the server would do me no good since I need to hit reload to access them. There is the workaround to that issue which is to set the cache expiration of the page to an earlier time or to the exact time, however this only half works for me. I am using a tabbed user control on the page as well. If this is done from the initial tab it all works as expected, but if submitted from the secondary tab I get a nasty 'Warning: Page has expired' browser message. The issue is essentially viewstate with javascript and DHTML. I know there is an answer out there, I'm just having a LOT of trouble finding it.
|
|
|
|
|
If the page is pure HTML, and no Server Side code (for the page in question):
You could cache the last used function, and it's parameters in a cookie. And to make sure also you could set the cookie to expire after say 5min. This (mostly) works in my pages it's not the best solution, but i haven't seen anything better yet...
|
|
|
|
|
I appreciate your response, but again, I can't use cookies.
|
|
|
|
|
Arcond wrote: This is because the page is loaded from local cache
You can solve this problem by disabling the cache from the ASP.NET application, but I don't know how ?
|
|
|
|
|
Iam working in paging using valuelist librarytag in struts but iam not getting proper results while connecting database using hibernate.valuelist supports spring. i dont want to use applicationcontext.xml .pls anybody guide me in resolving this
amutha
|
|
|
|