|
Try this:
okButton.onclick = SomeFunction;
|
|
|
|
|
Sir;
I took your advice and replaced the line
okButton.setAttribute('onclick', 'javascript:$find(\'' + this.get_element().id + '\').AcceptDialog(\'' + okButton.dialogResult + '\');');
with
okButton.messageboxid = this.get_element().id;
okButton.onclick = function() { $find(this.messageboxid).AcceptDialog(this.dialogResult) };
by setting the onclick event to a reference of type function, but i use it in a new function because i want to pass a parameter to function AcceptDialog and I add messageboxid to the button because I lose context when the button is clicked.
this works great, but is there any way else to do so?
Help people,so poeple can help you.
|
|
|
|
|
Is there a reason you want to do it another way? Here is one small trick that can make your code look a little cleaner:
function create_handleOkClick (boxId, dialogResult) {
return function() {$find(boxId).AcceptDialog(dialogResult); };
}
okButton.onclick = create_handleOkClick(this.messageboxid, this.dialogResult);
You could also do this:
function create_handleOkClick (instance) {
return function() {$find(instace.messageboxid).AcceptDialog(instance.dialogResult); };
}
okButton.onclick = create_handleOkClick(this);
|
|
|
|
|
AspDotNetDev wrote: Is there a reason you want to do it another way?
No, just trying to learn other techniqes.
i liked the "return function()" this would be better then editing code for 7 buttons.
and one more thing, be gentle with me so i can love you
and as you maight know my heart is so weak (you could kill me with your "Is there a reason you want to do it another way?").
100 and have a nice day;
Help people,so poeple can help you.
|
|
|
|
|
Sir;
I worked on this:
var create_handler = function(context, method, prameter) {
var methodname = 'AcceptDialog';
return function() { context[methodname](prameter); };
}
button1.onclick = create_handler(this, this.AcceptDialog, button1.dialogResult);
I added the parameter 'method' as i may need to invoke one of the three methods; this.AcceptDialog(), this.Close(), this.DoPostBack(). The 'context' parameter i used it instead of function $find() .
what happend whit me is that I couldn't extract the method name
so I am wondering if you could help me with this;
Help people,so poeple can help you.
|
|
|
|
|
I am a little confused as to what you are after, but here are a few samples that may demonstrate what you are looking for:
var create_handler = function (context, methodName, parameter) {
create_handler[methodName](context, parameter);
};
create_handler.AcceptDialog = function (context, parameter) {
alert("Accepting...");
};
create_handler.Close = function (context, parameter) {
alert("Closing...");
};
create_handler.DoPostBack = function (context, parameter) {
alert("Posting...");
};
create_handler(this, "AcceptDialog", "a parameter");
create_handler(this, "Close", "a parameter");
create_handler(this, "DoPostBack", "a parameter");
And another:
var create_handler = function (context, method, parameter) {
method(context, parameter);
};
create_handler.AcceptDialog = function (context, parameter) {
alert("Accepting...");
};
create_handler.Close = function (context, parameter) {
alert("Closing...");
};
create_handler.DoPostBack = function (context, parameter) {
alert("Posting...");
};
create_handler(this, create_handler.AcceptDialog, "a parameter");
create_handler(this, create_handler.Close, "a parameter");
create_handler(this, create_handler.DoPostBack, "a parameter");
And another:
var myContext = "hello";
var create_handler = function (context, method, parameter) {
method.call(context, parameter);
};
create_handler.AcceptDialog = function (parameter) {
alert("Accepting..." + this);
};
create_handler.Close = function (parameter) {
alert("Closing..." + this);
};
create_handler.DoPostBack = function (parameter) {
alert("Posting..." + this);
};
create_handler(myContext, create_handler.AcceptDialog, "a parameter");
create_handler(myContext, create_handler.Close, "a parameter");
create_handler(myContext, create_handler.DoPostBack, "a parameter");
|
|
|
|
|
Sir;
I liked the last one of Function.call() this would serve my alot.
For what I am after, please go to Message Box Control[^] and Browes the Code[^] of //MyControls/MyControls/script/MessageBox.js lines 37 to 229 and you will get it.
in your way please tell me what do yoyu think about the overall article and alse the control.
Regards;
Help people,so poeple can help you.
|
|
|
|
|
Hi,
By using JqueryCurrency i am reading the currency symbold based on locale, but when i am trying to read the UK currency symbol, instead of pound symbol it is reading some junk data.
Any one faced the same problem please let me know the solution to read the pound symbol.
Thanks in Advance.
|
|
|
|
|
|
Hi,
I have a usercontrol embedded in my content page.This usercontrol has a text box in it.
The label and regular expression validators on the page use ucid:txtboxid for associatedcontrolid/ControlToValidate respectively.
Now i try to populate the textbox in usercontrol using jquery as follows:
<br />
$("#<%= ucid:txtboxid.ClientID %>").val(myvalue);<br />
this gives a compilation error. I tried a few combinations of brackets but no luck.I then tried
<br />
$("#<%= ucid.ClientID %>").val(myvalue);<br />
and it builds fine but value doesn't get assigned at runtime.
How do I populate the usercontrol textbox?
Thanks
|
|
|
|
|
Say you have this user control, "Hello.ascx":
<%@ Control Language="C#" %>
<asp:TextBox ID="txtInfo" runat="server" />
You can then get the ClientID of txtInfo using FindControl from "Default.aspx":
<%@ Page Language="C#" %>
<%@ Register Src="~/Hello.ascx" TagPrefix="my" TagName="Hello" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Sub-Control Client ID</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
<my:Hello ID="helloWorld" runat="server" />
<script type="text/javascript">
$("#<%= helloWorld.FindControl("txtInfo").ClientID %>").val("Hello World");
</script>
</div>
</form>
</body>
</html>
You could probably also add a property to your Hello control that returns the ClientID of txtInfo, then you'd simply get the ID by saying helloWorld.InfoClientID .
|
|
|
|
|
|
When Call this function like using escape it should throw the error like 'missing ) after argument list'
How should eliminate this problem...anybody having ideas...
Thanks in advance
|
|
|
|
|
You have to escape the ' in a string literal with a \
Tooltip(true,escape('Benito\'s Taco Shop'),event)
or you could wrap the string in double-quotes instead:
Tooltip(true,escape("Benito's Taco Shop"),event)
|
|
|
|
|
Hi guys,
I work with EXT JS Framework.I want to place my icon on the left of the fieldlabel of my textField.my code is :
var labelDownloadReport = new Ext.ux.StaticTextField ({
readOnly : true,
scope : this,
fieldLabel : '<a href="javascript: app.Communication.Edit_Cb.downloadReport">Télécharger </a>',
labelSeparator : '',
hidden : this.isNew (),
height : '0',
width : '450',
ctCls : 'app-icon-attachment',
renderer : app.Communication.Edit_Cb.downloadReport
});
my css is :
.app-icon-attachment
{
width : 11px;
height : 11px;
background-repeat : no-repeat;
text-align : right;
background-position : left;
padding-left : 10%;
padding-right : 10%;
background-image : url('../../img/communication/attachment.png') !important;
}
the problem is the icon is always placed on the right of the textField
ty
|
|
|
|
|
guys;
do you know how to Decode Query String parameters in javascript (e.i. 'Code%20Project' to 'Code Project' ).
Help people,so poeple can help you.
|
|
|
|
|
|
No, Sir;
I am not talking about that.
thank you anyway;
100
Help people,so poeple can help you.
|
|
|
|
|
The simple way to do this is to use decodeURI. Funnily enough, you can use encodeURI to encode a URI as well.
|
|
|
|
|
thank you, man. +5
good to learn a new pre defined function
but what i need is to decode a string containing the codes '%24' and '%2F' to the charactors '$' and '/'
so i defined the functions as
function UrlEncode (strinput) {
var outcome = new String(strinput);
var replacements = ['%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D'];
var entities = ['!', '*', '\'', '(', ')', ';', ':', '@', '&', '=', '+', '$', ',', '/', '?', '%', '#', '[', ']'];
var i = 0;
for (i = 0; i < entities.length; i++)
outcome = outcome.replace(entities[i], replacements[i]);
return outcome;
}
but it replaces just the first occurrence of any code.
what mistake i have done?
Help people,so poeple can help you.
|
|
|
|
|
In javascript we have built in method like unescape and escape
escape - method is used to encode
unescape -method is used to decode
(i.e)
var encodeSymbol = unescape("!");
encode the symbol ! to("%21")
var decodeSymbol = unescape("%21");
decode the %21 to symbol !
|
|
|
|
|
Another couple of functions; 100 , Man.
Sir;
I found on W3Schools this note
Note: The escape() function should not be used to encode URIs. Use the encodeURI() function instead.
Could you please tell me why.
*Please consider the function decodeURIComponent()
Help people,so poeple can help you.
modified on Thursday, May 26, 2011 3:37 AM
|
|
|
|
|
Abu AlHassan,
go through this link i think u may get idea.
http://www.albionresearch.com/misc/urlencode.php
|
|
|
|
|
Thank you, sivaguru, for link and also for calling me 'Abu AlHassan'; you know i like this name.
100 , Man.
Help people,so poeple can help you.
|
|
|
|
|
|