On Jul 16, 1:55 am, Peter <pete...@circle-consulting.co.nzwrote:
On Jul 15, 11:16 pm, nahid <nahid...@gmail.comwrote:
On Jul 15, 4:28 pm, Peter <pete...@circle-consulting.co.nzwrote:
I have a button on my ASP.NET 2.0 web page labelled "Copy to
Clipboard" which must use server side code to format some data in a
specific manner and then copy it to the client clipboard so it can be
pasted into another application. Initially I planned to have the
server-side code put the data string into a cookie and then use a
client-side Javascript function referenced in the button's
OnClientClick attribute to copy the contents of the cookie to the
client clipboard. However, to my display I've just figured out that
client-side code is always executed before server events.
Can someone give me an idea of how I can achieve what I need to be
able to do. Thanks.
Peter,
hi,
you can think about ajax. Format your clipboard data in a ajax call
and in call back put in in clipboard
like if you use ajax pro...
//html file
<input type="button" class="button" onclick="SubmitForFormat();"
value="Finish">
//js file
function SubmitRegistrationAJ()
{
PageMethods.SubmitForFormat(callBack_CopyToClipboa rd);
}
function callBack_CopyToClipboard(reselt)
{
//lets say
window.clipboardData.setData('text', reselt);
}
//server side code cs file
[WebMethod]
public static string SubmitForFormat()
{
return frmatedstring;
}
or you can use hidden field and onbody load always check if anything
in hidden field and then copy it to clipboard
nahidhttp://nahidulkibria.blogspot.com/http://www.kaz.com.bd
Thanks. I've not dabbled with AJAX before so will look into what
you've suggested. Is the "ajax pro" you mention part of ASP.NET or
something I must add to my development environment? I've just had a
quick look on MSDN and it seems that ASP.NET 2.0 does have some AJAX
capability. Thanks for your help.- Hide quoted text -
- Show quoted text -
hi,
im talk about
http://www.codeplex.com/AjaxPro/ AJAX frameworks to
make you pages ajax enable.
simply think PageMethods as web service and after call back result
you put data to clipboard.
if you consider microsoft ajax framework (
http://ajax.asp.net/) try
following way...i'm not try this but should work in your case
<script type="text/javascript">
function AfterPostback()
{
//lets say
window.clipboardData.setData('text', reselt);
}
function PageRequestManagerPropertyChanged(sender, args)
{
if (args.get_propertyName() == "inPostBack")
{
if (!$object("_PageRequestManager").get_inPostBack())
AfterPostback();
}
}
function pageLoad()
{
$object("_PageRequestManager").propertyChanged.add (PageRequestManagerPropertyChanged);
}
</script>
<div>
<atlas:ScriptManager EnablePartialRendering="true" ID="ScriptManager1"
runat="server">
</atlas:ScriptManager>
<atlas:UpdatePanel runat="server" Mode="Conditional"
ID="UpdatePanel1">
<ContentTemplate>
<asp:Button ID="Clipboard" runat="server" Text="Copy to Clipboard" />
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="UpdateTime" EventName="Click" />
</Triggers>
</atlas:UpdatePanel>
</div>