|
LancashireLad wrote: a generic sub (borrowed from an article by Jim Stall)
I'm not sure what you are referring to..
Have you checked this one?? Custom Javascript Dialog[^]
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.
|
|
|
|
|
Thanks, I'll take a look at the samples you pointed to!
|
|
|
|
|
Michael,
Thanks for pointing me to the blog you did on using the prompt funtion. It's helpful but is not solving the problem I'm having.
I'm a novice Javascript programmer so it may be something elemental that I'm missing. According to articles I've read on using confirm() is that if the user clicks Cancel to the OK/Cancel prompt, nothing happens (which is what I want). If they click OK, a postback occurs and executes the code in my button click event. What I'm finding is that regardless of whether OK or Cancel is clicked, the client does a postback. This means I have no way of knowing whether they clickede OK or Cancel.
Original article: http://aspnet.4guysfromrolla.com/articles/021104-1.aspx
(see response http://www.thescripts.com/forum/thread115874.html)
I hope this makes sense and thanks in advance for any help.
|
|
|
|
|
Did you check the sample? There are two parts (using normal js confirm and js custom dialog)in this article. there is a way to know whether the user clicks "delete it" button ("OK" button in your case), "cancel " button and "close" button at the top of custom dialog.
it said:
If the user click “cancel” or “close” image, we call “hideWindow()” function. In this function, we hide the JS dialog and set the variable “g_IsWindowShown” to true. (We also return “false” in this function since we dont want the Server-side code to execute.)
If the user click “Delete It” button then we call “deleteit()” function. In this function, we set the text of textbox to hidden field so that this value can be read from Server-side script. then, we fire the button client event of “Delete” button (not “Delete It” button.) then, showWindow() function will be invoked again. At that time, the variable “g_IsWindowShown” will be true. After that, we just return “true” from this function. So, the Server-side code will be executed.
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.
|
|
|
|
|
You are only adding the event the first time the page is loaded. If you do a postback for any reason, the event isn't added to the control when the page loads again.
Verify that the code is actually present in the generated code, and if it is, show us what the generated code looks like.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks for responding.
I removed the IsPostBack on the load event and it made no difference. The confirm function is executing. The generated code is below. If you hit cancel I was under the impression that no postback would occur. However, it does and the button code click event fires on the server when you click cancel. Is it your understanding that a postback should not occur if you click Cancel on a confirm dialog box?
<a onclick="return confirm('Are you sure you want to delete this address?');" id="btnDelete" href="javascript:__doPostBack('btnDelete','')">Delete</a></div>
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
Thanks for your time.
|
|
|
|
|
This is very odd - yes, hitting Cancel shouold stop the postback; and you are also quire correct in that you need only add the JS once, the first time the page is loaded.
There really is no reason I can see why this shouldn't work - unless you have javascript disabled in your browser, perhaps..?
The simple page below, based on your code, works fine for me in both IE and Firefox - try copying it to your web-folder and running it. If it works, then there is something going on elsewhere on your page...
Fred
<%@ Page Language="vb" debug="true" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Not Page.IsPostBack Then
CreateConfirmBox(btnDelete, "Are you sure you want to delete this user?")
else
litX.text += "Postback<br>"
End If
End Sub
Private Sub CreateConfirmBox(ByRef btn As WebControls.LinkButton, ByVal strMessage As String)
btn.Attributes.Add("onclick", "return confirm('" & strMessage & "');")
End Sub
</script>
<HTML>
<HEAD>
<title></title>
</HEAD>
<body >
<form id="Form1" runat="server">
<asp:Literal runat="server" id="litX"></asp:Literal>
<asp:LinkButton ID="btnDelete" runat="server" Text="Delete" />
</form>
</body>
</HTML>
|
|
|
|
|
Fred,
Thanks for confirming that I am not going crazy! I cut and pasted your code into an empty ASPX form and still get the same behavior. When I click Cancel on the confirm() dialog, it does a postback! I've tried running the code from a local IIS and from an ISP and get the same behavior. Unless, you have any suggestions, I guess I need to open an incident with Microsoft to get to the bottom of this.
Thanks!
|
|
|
|
|
Okay,
The mystery is solved. It turns out that I'm running McAFee antivirus software. It has two browser components that are meant to catch phishing activities. I disabled these two comnponents and everything works fine.
BTW, McAfee SUCKS. They have been sending out daily builds recently requiring reboots. These guys are clueless.
Note to self, GET RID OF MCAFEE
Thanks to all for helping me work through this.
|
|
|
|
|
I am working on a web application which require the distance between 2 location (zip codes). Could someone help me how to approach it or how to implement it??? Thanks in advance.
|
|
|
|
|
Zip codes doesn't contain any information that you can use to calculate distance. You need a database that either contains the physical location of zip codes or distances between zip codes.
---
single minded; short sighted; long gone;
|
|
|
|
|
|
Hi All. i am making one simple website using microsoft ajax framework 1.0. in that i need to get or set value of disabled dropdown list in java script. when i am trying to get value of ddl in javascript it is allowing me get value till it is enabled, but not allowing to assing value to it.
condition is going worse once i will make ddl disabled. then i am not able to get it's value or assing any value. some where i got answer that if we disable ddl in java script so we can't get it's value. so i tried with disabling in page itself then enabling it in java script then assigned value to it then made it disabled, this all in java script, but after disabling value is gone.
my javascript function is like:
/////////////////////////////////////////
function setcontrols(result)
if(result!="")
{
// ....
//some code to get ID's of controls
//....
var client = result.split(",");
clientName.value=client[0]; // clientName is one asp.net 2.0 textbox
oA.value = client[1]; // oA is asp.net 2.0 dropdownlist which causing problem
alert(window.oA.value); //not working if ddl is disabled otherwise working fine
window.oA.value = "mystring"; // this is not working independent to ddl is disabled or enabled
}
i tried in many ways but didn't get solution. i am working with master page so i have used unique IDs to get controls in this function, so that is not issue as i am getting all properties of controls in this function.
please help me...
Akhilesh Singh
|
|
|
|
|
You don't use value property to get the selected item in a select element, you use the selectedIndex property.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks for reply Guffa but as you might be knowing that if any asp.net drop down list is disabled then we can get it's value directly using dropdownID.value, this i have done some times before also and it worked, but here i am not getting why i am not able to get value by ddlID.value...
do you have any idea? if yes plz let me know... thanks in advance
Akhilesh Singh
|
|
|
|
|
Hi friends ..
i migrated asp.net project from 1.1 to 2.0 in and now i am using HTML 4.01 here Overflow property is not working in Mozila browser but its working in IE , how to fix this error please help me
Thank you ...
Reg and Thanks
Nanthakumar
|
|
|
|
|
|
|
I am working on a web application. I don’t wan to give menu bar to users. I want to hide toolbar when user logged into application. I tried this code
string strScript = "";
strScript += "window.open('" + strRedirect + "','_blank','menubar=no,resizable=yes');";
strScript += "";
if (!Page.IsStartupScriptRegistered("openclientScript"))
{
Page.RegisterStartupScript("openclientScript", strScript);
}
With this code i was able to open home page without menu bar. But that page opens in a new window. I don’t know the way to close the window from which user logs in. Can any body help me? I tried to open the home page in the same window using _self parameter but menu bar was still there.
|
|
|
|
|
garimajain_mca wrote: I tried to open the home page in the same window using _self parameter but menu bar was still there.
You can not. It is for security reasons.
garimajain_mca wrote: . I don’t know the way to close the window from which user logs in.
You can not close the window that you have not opened without browser prompts. There are undocumented methods like naming the window.opener to non-null but these would work only till the web browser does not recieve vendor updates on its security vulnerabilities.
|
|
|
|
|
Hi
I open a pop window fom my application using window.open(). From this new window I download a file, when I select the "Open" from the download dialog the pop up window is closed. This behaviour is there only in windows 2003. please help me in this issue
Thanks in advance
|
|
|
|
|
Hai guys
How to stroe/Retrive Documents into Sql Server 2000.
This code is urgent.if any one knows this pls forward to me
Naresh_Sairam@yahoo.com
Adapala
|
|
|
|
|
|
Read the forum guidelines. Highlights include:
1. We don't care if it is urgent.
2. You should not post your email address
3. For broad subjects use this fancy thing called GOOGLE.
4. These message boards are for more specific topics. Such as, your code to retrieve a document gets an error. Then we review the code and guide you.
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
i have a gridview which is storing a record .i want to generate a unique no while saving one record.
the format should be like (pscode(2place),year(4place)and num(4place))
example:--01-2007-0001
where ps_code is char(2),
year come form date-which is of date and time datattype
and the last 4 place are char(4),
where ps_code and date are the field of my data base.i want retrive ps_code and year from my database to generate the unique number.
can tell me how will i do it?
i am devloping a web applcation where the backend is vb.net2005.
|
|
|
|