J
JJ
Hi,
I am working on a proj and was thinking of creating a Document object
that would hold filepath and doc name. And in this Document obj. when
page that is using it loads I would call a document obj method to
initialize the following javascipt:
<code>
if (new FileInfo(String.Format("{0}.pdf", strFile)).Exists)
{
string strJScript = String.Format(@"
<script language='javascript'>
function lnkLV_OnClick()
{{
window.open('{0}', '_blank', 'scrollbars=no,toolbar=no,location=no,
directories=no, status=yes, menubar=no, resizable=yes');
return false;
}}
</script>
", Server.UrlEncode(strFile));
lnkLV.Attributes.Add("onClick", "return lnkLV_OnClick();");
Page.RegisterClientScriptBlock("lnkLV_OnClick", strJScript);
}
</code>
So this code basically adds an "OnClick" link button event and
registers the javascript. Now there is multiple times on the page that
uses this same identical code so I thought I would add it to a document
class and then call a method to activate the links one by one. So my
question is how can I make this generic in the document class? I would
need to pass linkbutton in question to the method. How could I pass the
refering page to the method so I can RegisterClientScriptBlock
effectivily?
Also since I have multiple documents and each one would be associated
with a link button. How would I store these document names? What I am
not sure of is should I create just one document obj and use some
technique to store document filenames in that one obj. like in an
arraylist?
Thanks,
JJ
I am working on a proj and was thinking of creating a Document object
that would hold filepath and doc name. And in this Document obj. when
page that is using it loads I would call a document obj method to
initialize the following javascipt:
<code>
if (new FileInfo(String.Format("{0}.pdf", strFile)).Exists)
{
string strJScript = String.Format(@"
<script language='javascript'>
function lnkLV_OnClick()
{{
window.open('{0}', '_blank', 'scrollbars=no,toolbar=no,location=no,
directories=no, status=yes, menubar=no, resizable=yes');
return false;
}}
</script>
", Server.UrlEncode(strFile));
lnkLV.Attributes.Add("onClick", "return lnkLV_OnClick();");
Page.RegisterClientScriptBlock("lnkLV_OnClick", strJScript);
}
</code>
So this code basically adds an "OnClick" link button event and
registers the javascript. Now there is multiple times on the page that
uses this same identical code so I thought I would add it to a document
class and then call a method to activate the links one by one. So my
question is how can I make this generic in the document class? I would
need to pass linkbutton in question to the method. How could I pass the
refering page to the method so I can RegisterClientScriptBlock
effectivily?
Also since I have multiple documents and each one would be associated
with a link button. How would I store these document names? What I am
not sure of is should I create just one document obj and use some
technique to store document filenames in that one obj. like in an
arraylist?
Thanks,
JJ