Design question

P

Peter

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,
 
N

nahid

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_CopyToClipboard);
}

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

nahid
http://nahidulkibria.blogspot.com/
http://www.kaz.com.bd
 
P

Peter

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.

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_CopyToClipboard);

}

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.
 
N

nahid

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_CopyToClipboard);

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>
 
N

nahid

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,

what sort of formatting you need ?? is it not possible using java
script to do that in client?? hope that make problem simpler

nahid
http://nahidulkibria.blogspot.com/
http://www.kaz.com.bd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top