Thursday, March 22, 2012
Suppress Crystal Reports Section in VB .Net 2003
Now that I have moved to plain VB .Net 2003 with Crystal Reports 10, this command will not work.
Anyone know the correct syntax for this line in VB .Net for Crystal 10?
Here is my initial code in my web page.
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO
Dim crpt As New ReportDocument
crpt.Load("C:\inetpub\wwwroot\McClure\CigUnitsRpt.rpt")
ThanksBump
For anyone interested, this is the way to do it with VB .Net 2003 and Crystal 10
dim crpt as New ReortDocument()
crpt.Load("PathAndFileName")
crpt.ReportDefinition.Sections(6).SectionFormat.EnableSuppress = True
Suppress Form Action
Namespace Confirm
Public Class ShowConfirm : Inherits Button
Private strConfirmMsg As String
Public Property ConfirmMessage() As String
Get
ConfirmMessage = strConfirmMsg
End Get
Set(ByVal value As String)
strConfirmMsg = value
End Set
End Property
Protected Overrides Sub AddAttributesToRender(ByVal Output As
HtmlTextWriter)
MyBase.AddAttributesToRender(Output)
Output.AddAttribute(HtmlTextWriterAttribute.OnClic k,
"ConfirmMsg()")
End Sub
Protected Overrides Sub RenderContents(ByVal Output As
HtmlTextWriter)
Output.Write(vbCrLf)
Output.Write("<script language='JavaScript'>")
Output.Write(vbCrLf)
Output.Write("function ConfirmMsg(){")
Output.Write(vbCrLf)
Output.Write("var answer = confirm('")
Output.Write(strConfirmMsg)
Output.Write("')")
Output.Write(vbCrLf)
Output.Write("location.href = window.location.href +
'?Proceed=' + answer")
Output.Write(vbCrLf)
Output.Write("}")
Output.Write(vbCrLf)
Output.Write("</script>")
End Sub
End Class
End Namespace
Using VBC, I compiled the above into 'Confirm.dll'. This is how I am
using the above custom control in an ASPX page (assume that the ASPX
page is named Confirm.aspx):
<%@dotnet.itags.org. Register Assembly="Confirm" Namespace="Confirm" TagPrefix="CC" %>
<form EnableViewState="true" runat="server">
<CC:ShowConfirm ID="ShowConfirm1" ConfirmMessage="WANNA EXIT?"
Text="EXIT" runat="server"/>
</form>
Note the
Output.Write("location.href = window.location.href + '?Proceed=' +
answer")
line in the VB class file code. When the ASPX page gets rendered, it
displays a Button. Conventionally, when a Button is clicked in an ASPX
page, it posts back to itself using the POST method. When the Button in
the above custom control is clicked, a JavaScript confirm dialog
pops-up with 2 buttons - 'OK' & 'Cancel'. If 'OK' is clicked, the value
of the JavaScript variable 'answer' is true & if 'Cancel' is clicked,
the value of the variable 'answer' is false.
What I want is irrespective of whether a user clicks the 'OK' or
'Cancel' button in the confirm dialog, instead of posting back to
itself using the conventional POST method, I want the ASPX page to post
to itself BUT with a querystring 'Proceed=<value>' appended i.e. I want
to suppress the conventional post & instead add the querystring so that
I can find out whether the user has clicked the 'OK' button or the
'Cancel' button in the confirm dialog. If the user clicks 'OK', he will
be taken to
http://myserver/aspx/Confirm.aspx?Proceed=true
If the user clicks 'Cancel' in the confirm dialog, he will be taken to
http://myserver/aspx/Confirm.aspx?Proceed=false
Can this be done in anyway?Anyone?
rn5a@.rediffmail.com wrote:
Quote:
Originally Posted by
A custom server control has a Button.
>
Namespace Confirm
Public Class ShowConfirm : Inherits Button
Private strConfirmMsg As String
Public Property ConfirmMessage() As String
Get
ConfirmMessage = strConfirmMsg
End Get
Set(ByVal value As String)
strConfirmMsg = value
End Set
End Property
>
Protected Overrides Sub AddAttributesToRender(ByVal Output As
HtmlTextWriter)
MyBase.AddAttributesToRender(Output)
Output.AddAttribute(HtmlTextWriterAttribute.OnClic k,
"ConfirmMsg()")
End Sub
>
Protected Overrides Sub RenderContents(ByVal Output As
HtmlTextWriter)
Output.Write(vbCrLf)
Output.Write("<script language='JavaScript'>")
Output.Write(vbCrLf)
Output.Write("function ConfirmMsg(){")
Output.Write(vbCrLf)
Output.Write("var answer = confirm('")
Output.Write(strConfirmMsg)
Output.Write("')")
Output.Write(vbCrLf)
>
Output.Write("location.href = window.location.href +
'?Proceed=' + answer")
Output.Write(vbCrLf)
Output.Write("}")
Output.Write(vbCrLf)
Output.Write("</script>")
End Sub
End Class
End Namespace
>
Using VBC, I compiled the above into 'Confirm.dll'. This is how I am
using the above custom control in an ASPX page (assume that the ASPX
page is named Confirm.aspx):
>
<%@. Register Assembly="Confirm" Namespace="Confirm" TagPrefix="CC" %>
>
<form EnableViewState="true" runat="server">
<CC:ShowConfirm ID="ShowConfirm1" ConfirmMessage="WANNA EXIT?"
Text="EXIT" runat="server"/>
</form>
>
Note the
>
Output.Write("location.href = window.location.href + '?Proceed=' +
answer")
>
line in the VB class file code. When the ASPX page gets rendered, it
displays a Button. Conventionally, when a Button is clicked in an ASPX
page, it posts back to itself using the POST method. When the Button in
the above custom control is clicked, a JavaScript confirm dialog
pops-up with 2 buttons - 'OK' & 'Cancel'. If 'OK' is clicked, the value
of the JavaScript variable 'answer' is true & if 'Cancel' is clicked,
the value of the variable 'answer' is false.
>
What I want is irrespective of whether a user clicks the 'OK' or
'Cancel' button in the confirm dialog, instead of posting back to
itself using the conventional POST method, I want the ASPX page to post
to itself BUT with a querystring 'Proceed=<value>' appended i.e. I want
to suppress the conventional post & instead add the querystring so that
I can find out whether the user has clicked the 'OK' button or the
'Cancel' button in the confirm dialog. If the user clicks 'OK', he will
be taken to
>
http://myserver/aspx/Confirm.aspx?Proceed=true
>
If the user clicks 'Cancel' in the confirm dialog, he will be taken to
>
http://myserver/aspx/Confirm.aspx?Proceed=false
>
Can this be done in anyway?
Suppress Form Action
Namespace Confirm
Public Class ShowConfirm : Inherits Button
Private strConfirmMsg As String
Public Property ConfirmMessage() As String
Get
ConfirmMessage = strConfirmMsg
End Get
Set(ByVal value As String)
strConfirmMsg = value
End Set
End Property
Protected Overrides Sub AddAttributesToRender(ByVal Output As HtmlTextWriter)
MyBase.AddAttributesToRender(Output)
Output.AddAttribute(HtmlTextWriterAttribute.OnClick, "ConfirmMsg()")
End Sub
Protected Overrides Sub RenderContents(ByVal Output As HtmlTextWriter)
Output.Write(vbCrLf)
Output.Write("<script language='JavaScript'>")
Output.Write(vbCrLf)
Output.Write("function ConfirmMsg(){")
Output.Write(vbCrLf)
Output.Write("var answer = confirm('")
Output.Write(strConfirmMsg)
Output.Write("')")
Output.Write(vbCrLf)
Output.Write("location.href = window.location.href + '?Proceed=' + answer")
Output.Write(vbCrLf)
Output.Write("}")
Output.Write(vbCrLf)
Output.Write("</script>")
End Sub
End Class
End Namespace
Using VBC, I compiled the above intoConfirm.dll. This is how I am using the above custom control in an ASPX page (assume that the ASPX page is namedConfirm.aspx):
<%@dotnet.itags.org. Register Assembly="Confirm" Namespace="Confirm" TagPrefix="CC" %
<form EnableViewState="true" runat="server">
<CC:ShowConfirm ID="ShowConfirm1" ConfirmMessage="WANNA EXIT?" Text="EXIT" runat="server"/>
</form>
Note the
Output.Write("location.href = window.location.href + '?Proceed=' + answer")
line (which is highlighted) in the VB class file code. When the ASPX page gets rendered, it displays a Button. Conventionally, when a Button is clicked in an ASPX page, it posts back to itself using the POST method. When the Button in the above custom control is clicked, a JavaScriptconfirm dialog pops-up with 2 buttons -OK &Cancel. IfOK is clicked, the value of the JavaScript variableanswer istrue & ifCancel is clicked, the value of the variableanswer isfalse.
What I want is irrespective of whether a user clicks theOK orCancel button in theconfirm dialog, instead of posting back to itself using the conventional POST method, I want the ASPX page to post to itself BUT with a querystringProceed=<value> appended i.e. I want to suppress the conventional post & instead add the querystring so that I can find out whether the user has clicked theOK button or theCancel button in theconfirm dialog. If the user clicksOK, he will be taken to
http://myserver/aspx/Confirm.aspx?Proceed=true
On the other hand, if the user clicksCancel in theconfirm dialog, he will be taken to
http://myserver/aspx/Confirm.aspx?Proceed=false
Can this be done in anyway?
Output.AddAttribute(HtmlTextWriterAttribute.OnClick, "ConfirmMsg();return false;")
Thanks, mate, your suggestion turned out to be a great one. Could you please tell me what role doesreturn=false; which you have appended afterConfirmMsg(), play here?
Going by your suggestion does add the querystringProceed=<value> at the end of the URL but there's a *** here. Suppose when a user clicks the server-side Button; he is shown the JavaScriptconfirm dialog with theOK &Cancel buttons. If the user clicksOK, then he is taken to
http://myserver/aspx/Confirm.aspx?Proceed=true
That's fine but if the user clicks the server-side Button once again & clicksCancel in theconfirm dialog, then he is taken to
http://myserver/aspx/Confirm.aspx?Proceed=true?Proceed=false
i.e. the querystring gets appended twice. In other words, a querystringProceed=<value> will go on getting appended at the URL wheneverOK &Cancel is clicked in the JavaScriptconfirm dialog. For e.g. if a user clicks eitherOK orCancel in theconfirm dialog 5 times, then the querystring will get appended one after the other 5 times.
Any workaround to overcome this?
Suppress Form Action
Namespace Confirm
Public Class ShowConfirm : Inherits Button
Private strConfirmMsg As String
Public Property ConfirmMessage() As String
Get
ConfirmMessage = strConfirmMsg
End Get
Set(ByVal value As String)
strConfirmMsg = value
End Set
End Property
Protected Overrides Sub AddAttributesToRender(ByVal Output As
HtmlTextWriter)
MyBase.AddAttributesToRender(Output)
Output.AddAttribute(HtmlTextWriterAttribute.OnClick,
"ConfirmMsg()")
End Sub
Protected Overrides Sub RenderContents(ByVal Output As
HtmlTextWriter)
Output.Write(vbCrLf)
Output.Write("<script language='JavaScript'>")
Output.Write(vbCrLf)
Output.Write("function ConfirmMsg(){")
Output.Write(vbCrLf)
Output.Write("var answer = confirm('")
Output.Write(strConfirmMsg)
Output.Write("')")
Output.Write(vbCrLf)
Output.Write("location.href = window.location.href +
'?Proceed=' + answer")
Output.Write(vbCrLf)
Output.Write("}")
Output.Write(vbCrLf)
Output.Write("</script>")
End Sub
End Class
End Namespace
Using VBC, I compiled the above into 'Confirm.dll'. This is how I am
using the above custom control in an ASPX page (assume that the ASPX
page is named Confirm.aspx):
<%@dotnet.itags.org. Register Assembly="Confirm" Namespace="Confirm" TagPrefix="CC" %>
<form EnableViewState="true" runat="server">
<CC:ShowConfirm ID="ShowConfirm1" ConfirmMessage="WANNA EXIT?"
Text="EXIT" runat="server"/>
</form>
Note the
Output.Write("location.href = window.location.href + '?Proceed=' +
answer")
line in the VB class file code. When the ASPX page gets rendered, it
displays a Button. Conventionally, when a Button is clicked in an ASPX
page, it posts back to itself using the POST method. When the Button in
the above custom control is clicked, a JavaScript confirm dialog
pops-up with 2 buttons - 'OK' & 'Cancel'. If 'OK' is clicked, the value
of the JavaScript variable 'answer' is true & if 'Cancel' is clicked,
the value of the variable 'answer' is false.
What I want is irrespective of whether a user clicks the 'OK' or
'Cancel' button in the confirm dialog, instead of posting back to
itself using the conventional POST method, I want the ASPX page to post
to itself BUT with a querystring 'Proceed=<value>' appended i.e. I want
to suppress the conventional post & instead add the querystring so that
I can find out whether the user has clicked the 'OK' button or the
'Cancel' button in the confirm dialog. If the user clicks 'OK', he will
be taken to
http://myserver/aspx/Confirm.aspx?Proceed=true
If the user clicks 'Cancel' in the confirm dialog, he will be taken to
http://myserver/aspx/Confirm.aspx?Proceed=false
Can this be done in anyway?Anyone?
rn5a@.rediffmail.com wrote:
> A custom server control has a Button.
> Namespace Confirm
> Public Class ShowConfirm : Inherits Button
> Private strConfirmMsg As String
> Public Property ConfirmMessage() As String
> Get
> ConfirmMessage = strConfirmMsg
> End Get
> Set(ByVal value As String)
> strConfirmMsg = value
> End Set
> End Property
> Protected Overrides Sub AddAttributesToRender(ByVal Output As
> HtmlTextWriter)
> MyBase.AddAttributesToRender(Output)
> Output.AddAttribute(HtmlTextWriterAttribute.OnClick,
> "ConfirmMsg()")
> End Sub
> Protected Overrides Sub RenderContents(ByVal Output As
> HtmlTextWriter)
> Output.Write(vbCrLf)
> Output.Write("<script language='JavaScript'>")
> Output.Write(vbCrLf)
> Output.Write("function ConfirmMsg(){")
> Output.Write(vbCrLf)
> Output.Write("var answer = confirm('")
> Output.Write(strConfirmMsg)
> Output.Write("')")
> Output.Write(vbCrLf)
> Output.Write("location.href = window.location.href +
> '?Proceed=' + answer")
> Output.Write(vbCrLf)
> Output.Write("}")
> Output.Write(vbCrLf)
> Output.Write("</script>")
> End Sub
> End Class
> End Namespace
> Using VBC, I compiled the above into 'Confirm.dll'. This is how I am
> using the above custom control in an ASPX page (assume that the ASPX
> page is named Confirm.aspx):
> <%@. Register Assembly="Confirm" Namespace="Confirm" TagPrefix="CC" %>
> <form EnableViewState="true" runat="server">
> <CC:ShowConfirm ID="ShowConfirm1" ConfirmMessage="WANNA EXIT?"
> Text="EXIT" runat="server"/>
> </form>
> Note the
> Output.Write("location.href = window.location.href + '?Proceed=' +
> answer")
> line in the VB class file code. When the ASPX page gets rendered, it
> displays a Button. Conventionally, when a Button is clicked in an ASPX
> page, it posts back to itself using the POST method. When the Button in
> the above custom control is clicked, a JavaScript confirm dialog
> pops-up with 2 buttons - 'OK' & 'Cancel'. If 'OK' is clicked, the value
> of the JavaScript variable 'answer' is true & if 'Cancel' is clicked,
> the value of the variable 'answer' is false.
> What I want is irrespective of whether a user clicks the 'OK' or
> 'Cancel' button in the confirm dialog, instead of posting back to
> itself using the conventional POST method, I want the ASPX page to post
> to itself BUT with a querystring 'Proceed=<value>' appended i.e. I want
> to suppress the conventional post & instead add the querystring so that
> I can find out whether the user has clicked the 'OK' button or the
> 'Cancel' button in the confirm dialog. If the user clicks 'OK', he will
> be taken to
> http://myserver/aspx/Confirm.aspx?Proceed=true
> If the user clicks 'Cancel' in the confirm dialog, he will be taken to
> http://myserver/aspx/Confirm.aspx?Proceed=false
> Can this be done in anyway?
Suppress keyboard, allow barcode scanner
application using a barcode scanner.
I've solved most of the problems, but one remains. The client want to
disable keyboard input (except at some remote sites where there won't
be a scanner). The session "knows" whether that site should be
keyboard enabled, but unfortunately the output from the scanner is in
the form of keypresses! So any attempt to capture and suppress
physical keypresses in script cannot differentiate between keyboard and
scanner.
Anyone got any ideas?
EdwardNope... you are probably out of luck, especially since it's a Web interface.
You would have to have some sort of client addin/component built and
installed but in the end even that may not help since the scanner simply
emulates a keyboard.
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"teddysnips@.hotmail.com" wrote:
> I posted yesterday about a project I'm involved in to build a login
> application using a barcode scanner.
> I've solved most of the problems, but one remains. The client want to
> disable keyboard input (except at some remote sites where there won't
> be a scanner). The session "knows" whether that site should be
> keyboard enabled, but unfortunately the output from the scanner is in
> the form of keypresses! So any attempt to capture and suppress
> physical keypresses in script cannot differentiate between keyboard and
> scanner.
> Anyone got any ideas?
> Edward
>
teddysnips@.hotmail.com wrote in news:1129216453.891262.133020
@.g47g2000cwa.googlegroups.com:
> I posted yesterday about a project I'm involved in to build a login
> application using a barcode scanner.
> I've solved most of the problems, but one remains. The client want to
> disable keyboard input (except at some remote sites where there won't
> be a scanner). The session "knows" whether that site should be
> keyboard enabled, but unfortunately the output from the scanner is in
> the form of keypresses! So any attempt to capture and suppress
> physical keypresses in script cannot differentiate between keyboard and
> scanner.
> Anyone got any ideas?
With IE, you cannot disable ALL keystrokes anyways.
If there is a such a requirement, you might want to consider using a
winforms login page instead... and somehow tie it into your web app.
--
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
you would need an write active/x control. you would then plug the scanner
into a seperate serial port (not the keyboard). the active/x control would
then poll the scanner's serial port for input, and raise an event on input
for client script to handle. you would use a hidden field that the client
script used to post the login id, so the keyboard would be disabled.
-- bruce (sqlwork.com)
<teddysnips@.hotmail.com> wrote in message
news:1129216453.891262.133020@.g47g2000cwa.googlegr oups.com...
>I posted yesterday about a project I'm involved in to build a login
> application using a barcode scanner.
> I've solved most of the problems, but one remains. The client want to
> disable keyboard input (except at some remote sites where there won't
> be a scanner). The session "knows" whether that site should be
> keyboard enabled, but unfortunately the output from the scanner is in
> the form of keypresses! So any attempt to capture and suppress
> physical keypresses in script cannot differentiate between keyboard and
> scanner.
> Anyone got any ideas?
> Edward
Bruce Barker wrote:
> you would need an write active/x control. you would then plug the scanner
> into a seperate serial port (not the keyboard). the active/x control would
> then poll the scanner's serial port for input, and raise an event on input
> for client script to handle. you would use a hidden field that the client
> script used to post the login id, so the keyboard would be disabled.
> -- bruce (sqlwork.com)
Thanks to you and to all other respondents. It's a fixed price
contract and we've agreed the work, so I'll just tell them to remove
the keyboard. That's the easiest solution, and the most foolproof
(until the scanner goes AWOL).
Edward
Suppress Masterpage
I am looking into reusing code to limit number of pages.
When ever I display a user's name on the site, It is with a hyperlink so you
can view the user profile in a popup window.
Is there a way to suppress the masterpage when a page is shown in my popup
windows?
JonasSure, just don't specify a master page for the popup window.
In the page header, don't add a MasterPageFile attribute.
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Jonas Pedersen" <qwert@.qwerty.com> wrote in message
news:O$vof7RJIHA.484@.TK2MSFTNGP06.phx.gbl...
> hi,
> I am looking into reusing code to limit number of pages.
> When ever I display a user's name on the site, It is with a hyperlink so
> you can view the user profile in a popup window.
> Is there a way to suppress the masterpage when a page is shown in my popup
> windows?
> Jonas
>
Suppress Masterpage
I am looking into reusing code to limit number of pages.
When ever I display a user's name on the site, It is with a hyperlink so you
can view the user profile in a popup window.
Is there a way to suppress the masterpage when a page is shown in my popup
windows?
JonasSure, just don't specify a master page for the popup window.
In the page header, don't add a MasterPageFile attribute.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Jonas Pedersen" <qwert@.qwerty.comwrote in message
news:O$vof7RJIHA.484@.TK2MSFTNGP06.phx.gbl...
Quote:
Originally Posted by
hi,
>
I am looking into reusing code to limit number of pages.
When ever I display a user's name on the site, It is with a hyperlink so
you can view the user profile in a popup window.
Is there a way to suppress the masterpage when a page is shown in my popup
windows?
>
Jonas
>
Suppress keyboard, allow barcode scanner
application using a barcode scanner.
I've solved most of the problems, but one remains. The client want to
disable keyboard input (except at some remote sites where there won't
be a scanner). The session "knows" whether that site should be
keyboard enabled, but unfortunately the output from the scanner is in
the form of keypresses! So any attempt to capture and suppress
physical keypresses in script cannot differentiate between keyboard and
scanner.
Anyone got any ideas?
EdwardNope... you are probably out of luck, especially since it's a Web interface.
You would have to have some sort of client addin/component built and
installed but in the end even that may not help since the scanner simply
emulates a keyboard.
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"teddysnips@.hotmail.com" wrote:
> I posted yesterday about a project I'm involved in to build a login
> application using a barcode scanner.
> I've solved most of the problems, but one remains. The client want to
> disable keyboard input (except at some remote sites where there won't
> be a scanner). The session "knows" whether that site should be
> keyboard enabled, but unfortunately the output from the scanner is in
> the form of keypresses! So any attempt to capture and suppress
> physical keypresses in script cannot differentiate between keyboard and
> scanner.
> Anyone got any ideas?
> Edward
>
teddysnips@.hotmail.com wrote in news:1129216453.891262.133020
@.g47g2000cwa.googlegroups.com:
> I posted yesterday about a project I'm involved in to build a login
> application using a barcode scanner.
> I've solved most of the problems, but one remains. The client want to
> disable keyboard input (except at some remote sites where there won't
> be a scanner). The session "knows" whether that site should be
> keyboard enabled, but unfortunately the output from the scanner is in
> the form of keypresses! So any attempt to capture and suppress
> physical keypresses in script cannot differentiate between keyboard and
> scanner.
> Anyone got any ideas?
With IE, you cannot disable ALL keystrokes anyways.
If there is a such a requirement, you might want to consider using a
winforms login page instead... and somehow tie it into your web app.
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
you would need an write active/x control. you would then plug the scanner
into a seperate serial port (not the keyboard). the active/x control would
then poll the scanner's serial port for input, and raise an event on input
for client script to handle. you would use a hidden field that the client
script used to post the login id, so the keyboard would be disabled.
-- bruce (sqlwork.com)
<teddysnips@.hotmail.com> wrote in message
news:1129216453.891262.133020@.g47g2000cwa.googlegroups.com...
>I posted yesterday about a project I'm involved in to build a login
> application using a barcode scanner.
> I've solved most of the problems, but one remains. The client want to
> disable keyboard input (except at some remote sites where there won't
> be a scanner). The session "knows" whether that site should be
> keyboard enabled, but unfortunately the output from the scanner is in
> the form of keypresses! So any attempt to capture and suppress
> physical keypresses in script cannot differentiate between keyboard and
> scanner.
> Anyone got any ideas?
> Edward
>
Bruce Barker wrote:
> you would need an write active/x control. you would then plug the scanner
> into a seperate serial port (not the keyboard). the active/x control would
> then poll the scanner's serial port for input, and raise an event on inpu
t
> for client script to handle. you would use a hidden field that the client
> script used to post the login id, so the keyboard would be disabled.
> -- bruce (sqlwork.com)
Thanks to you and to all other respondents. It's a fixed price
contract and we've agreed the work, so I'll just tell them to remove
the keyboard. That's the easiest solution, and the most foolproof
(until the scanner goes AWOL).
Edward
Suppress Postback on ImageButton
Is there a straightforward way to suppress the postback on an imagebutton? I want it to only fire the client onclick event.
Thanks!
If you return false from your OnClientClick event, then the postback will not be invoked.Thanks for the response. Hmmm...didn't seem to work in this example. Did I miss something?
==============================
<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ImageButton ID="ImageButton1" runat="server" Height="20px" Width="20px"
Style="z-index: 101; left: 180px; position: absolute; top: 128px"
OnClientClick="javascript:ImageClick(this)"/>
</div>
</form>
<script>
function ImageClick(varObj)
{
alert(varObj.tagName)
return false
}
</script>
</body>
</html>
==============================
Thanks for the response. Hmmm...didn't seem to work in this example. Did I miss something?
==============================
<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ImageButton ID="ImageButton1" runat="server" Height="20px" Width="20px"
Style="z-index: 101; left: 180px; position: absolute; top: 128px"
OnClientClick="javascript:ImageClick(this)"/>
</div>
</form>
<script>
function ImageClick(varObj)
{
alert(varObj.tagName)
return (false)
}
</script>
</body>
</html>
==============================
Just returnfalsefrom your ImageClick() javascript function, or do something like:
OnClientClick="javascript:ImageClick(this); return false;"/>
Got it. Works great. Thanks!
Suppress postback added to history WITHOUT smartnavigation
revent a link from being added to the browser history.
Has anyone found a way to implement this behaviour for page postbacks withou
t using smartnavigation?
SmartNavigation causes me too many javascript headaches. Anyone know of a ba
se page class (or something) that would accomplish that feature of smartnavi
gation?
Or perhaps you happen to be using CoolMenus and know how to fix the page so
it works with SmartNavigation :) ?
Thanks for any help.
From: Mark Petersen
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>emWuhAFdl0mktgkkLUxWpQ==</Id>Hello,
> Has anyone found a way to implement this behaviour for page postbacks without usin
g smartnavigation?
This article deals with that issue:
Maintaining Scroll Position on Postback (without SmartNavigation)
http://aspnet.4guysfromrolla.com/articles/111704-1.aspx
"Mark Petersen via .NET 247" wrote:
> I remember hearing that you could use javascript document.location.href to
prevent a link from being added to the browser history.
> Has anyone found a way to implement this behaviour for page postbacks with
out using smartnavigation?
> SmartNavigation causes me too many javascript headaches. Anyone know of a
base page class (or something) that would accomplish that feature of smartna
vigation?
> Or perhaps you happen to be using CoolMenus and know how to fix the page s
o it works with SmartNavigation :) ?
> Thanks for any help.
> --
> From: Mark Petersen
> --
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>emWuhAFdl0mktgkkLUxWpQ==</Id>
>
Suppress viewstate __viewstate rendering
File > Send > Page by E-mail, which opens up either Outlook or Outlook
Express with the HTML page content as the message body.
EXCEPT one nasty detail is that in the e-mail client, <input type="hidden">
elements are rendered as text boxes, which the __VIEWSTATE is one of, and so
the viewstate is displayed in a textbox at the top of the e-mail.
I've figured out some overrides and stuff to ensure that the textbox is
empty, so the HTML renders
<input type="hidden" name="__VIEWSTATE" value=""
but this still displays an empty TextBox.
Is there any way to prevent the HTML element from being written at all? I
found an interesting explanation of why it's hard at this address:
http://scottonwriting.net/sowblog/posts/1608.aspx
But couldn't translate that into a solution.
--
Jason
www.pettysconsulting.comJust a thought
Is there way to set style display as none for hidden variable ??
vinay
"Jason Pettys" wrote:
> I have an ASP.NET page that my client wants to e-mail. So in IE we choose
> File > Send > Page by E-mail, which opens up either Outlook or Outlook
> Express with the HTML page content as the message body.
> EXCEPT one nasty detail is that in the e-mail client, <input type="hidden">
> elements are rendered as text boxes, which the __VIEWSTATE is one of, and so
> the viewstate is displayed in a textbox at the top of the e-mail.
> I've figured out some overrides and stuff to ensure that the textbox is
> empty, so the HTML renders
> <input type="hidden" name="__VIEWSTATE" value="">
> but this still displays an empty TextBox.
> Is there any way to prevent the HTML element from being written at all? I
> found an interesting explanation of why it's hard at this address:
> http://scottonwriting.net/sowblog/posts/1608.aspx
> But couldn't translate that into a solution.
> --
> Jason
> www.pettysconsulting.com
I tried your suggestion but it did not work. See
http://pettysconsulting.com/test.htm. It has this defined:
<style type="text/css">
input { font-family: Verdana; display: none; }
</style
Neither type="text" nor type="hidden" elements are shown in the web page,
but both are shown in Outlook (with Verdana font).
"vinay" wrote:
> Just a thought
> Is there way to set style display as none for hidden variable ??
> vinay
> "Jason Pettys" wrote:
> > I have an ASP.NET page that my client wants to e-mail. So in IE we choose
> > File > Send > Page by E-mail, which opens up either Outlook or Outlook
> > Express with the HTML page content as the message body.
> > EXCEPT one nasty detail is that in the e-mail client, <input type="hidden">
> > elements are rendered as text boxes, which the __VIEWSTATE is one of, and so
> > the viewstate is displayed in a textbox at the top of the e-mail.
> > I've figured out some overrides and stuff to ensure that the textbox is
> > empty, so the HTML renders
> > <input type="hidden" name="__VIEWSTATE" value="">
> > but this still displays an empty TextBox.
> > Is there any way to prevent the HTML element from being written at all? I
> > found an interesting explanation of why it's hard at this address:
> > http://scottonwriting.net/sowblog/posts/1608.aspx
> > But couldn't translate that into a solution.
> > --
> > Jason
> > www.pettysconsulting.com
Have you considered a server side solution that generates an e-mail wth the
BodyFormat property of your MailMessage set to MailFormat.Html? Obviously I
am not familiar with your project but typically when someone wants to e-mail
a page, it's a report or flyer of some sort which is dynamically generated.
If this is the case, you may want to switch to a method that generates the
HTML and puts it in a PlaceHolder for the page output and can also be set as
the Body property of your MailMessage.
HTH
--
Dave Fancher
http://davefancher.blogspot.com
"Jason Pettys" <pettys@.nospam.nospam> wrote in message
news:355837CC-7A79-4163-83D8-B62A9D1EEEC2@.microsoft.com...
>I have an ASP.NET page that my client wants to e-mail. So in IE we choose
> File > Send > Page by E-mail, which opens up either Outlook or Outlook
> Express with the HTML page content as the message body.
> EXCEPT one nasty detail is that in the e-mail client, <input
> type="hidden">
> elements are rendered as text boxes, which the __VIEWSTATE is one of, and
> so
> the viewstate is displayed in a textbox at the top of the e-mail.
> I've figured out some overrides and stuff to ensure that the textbox is
> empty, so the HTML renders
> <input type="hidden" name="__VIEWSTATE" value="">
> but this still displays an empty TextBox.
> Is there any way to prevent the HTML element from being written at all? I
> found an interesting explanation of why it's hard at this address:
> http://scottonwriting.net/sowblog/posts/1608.aspx
> But couldn't translate that into a solution.
> --
> Jason
> www.pettysconsulting.com
That may be an option but it will take a lot of effort compared with File >
Send > Page by E-mail. I don't know that the HTML of the page can be grabbed
into a string like you suggest because it's a bunch of ASP.NET controls that
make up a timesheet entry/report page. The timesheet entry page is also the
timesheet report page by means of polymorphism to generate the correct data
controls (eg, textbox or label) depending on whether the timesheet is
editable. This is really slick because there's only one place to make
changes when modifying what a timesheet is.
Is there a way to grab the HTML that an arbitrary ASP.NET page will
generate? I tried HtmlForm.InnerText and .InnerHtml but that throws an
HttpException: "Cannot get inner content of FormActiveJobs because the
contents are not literal." I think that's a short description of what I'm
trying to explain in the above paragraph.
I think to do what you suggest I'd have to write a brand new view on the
timesheet data that can just dump HTML as a string. But that introduces
duplication that will have ongoing maintenance costs. I'd rather find a way
to hack the __VIEWSTATE so it doesn't show up.
If you know of a way to grab the HTML an arbitrary ASP.NET page will
generate into a string or stream I'd like to know of it.
Jason
"Dave Fancher" wrote:
> Have you considered a server side solution that generates an e-mail wth the
> BodyFormat property of your MailMessage set to MailFormat.Html? Obviously I
> am not familiar with your project but typically when someone wants to e-mail
> a page, it's a report or flyer of some sort which is dynamically generated.
> If this is the case, you may want to switch to a method that generates the
> HTML and puts it in a PlaceHolder for the page output and can also be set as
> the Body property of your MailMessage.
> HTH
> --
> Dave Fancher
> http://davefancher.blogspot.com
>
> "Jason Pettys" <pettys@.nospam.nospam> wrote in message
> news:355837CC-7A79-4163-83D8-B62A9D1EEEC2@.microsoft.com...
> >I have an ASP.NET page that my client wants to e-mail. So in IE we choose
> > File > Send > Page by E-mail, which opens up either Outlook or Outlook
> > Express with the HTML page content as the message body.
> > EXCEPT one nasty detail is that in the e-mail client, <input
> > type="hidden">
> > elements are rendered as text boxes, which the __VIEWSTATE is one of, and
> > so
> > the viewstate is displayed in a textbox at the top of the e-mail.
> > I've figured out some overrides and stuff to ensure that the textbox is
> > empty, so the HTML renders
> > <input type="hidden" name="__VIEWSTATE" value="">
> > but this still displays an empty TextBox.
> > Is there any way to prevent the HTML element from being written at all? I
> > found an interesting explanation of why it's hard at this address:
> > http://scottonwriting.net/sowblog/posts/1608.aspx
> > But couldn't translate that into a solution.
> > --
> > Jason
> > www.pettysconsulting.com
>
I was afraid you were going to say that ;) I'm not sure of a way to grab
the HTML before it has been rendered but since you may be able to get away
with a different type of client side solution.
On your read only view you could add a button to open a new window and
dynamically populate the contents with JavaScript. I have included some
sample code below. Basically, just wrap everything you want to include on
the page you want to e-mail in a <span> and dynamically write the contents
to the new window. If the areas you want to e-mail are non-linear you could
use the getElementsByTagName() or getElementsByName() functions instead.
You said that your client is using IE so this should work just fine. Keep
in mind that JavaScript must be enabled.
<script language="javascript">
function OpenEMailWindow() {
var newWindow = window.open("about:blank", "EMailWindow");
newWindow.document.write("<html><head><title>EMail Sample</title><link
rel=\"stylesheet\" href=\"styles\/default.css\"></head><body>");
newWindow.document.write(document.getElementById("EMailableContent").innerHTML);
newWindow.document.write("</body></html>");
}
</script>
...
<span id="EMailableContent">
All of your e-mailable contents would go here. Clicking the button below
will copy <b>everything</b> in this block to be copied to the new window.
</span>
<input type="button" value="EMail Friendly" onclick="OpenEMailWindow();">
...
HTH
--
Dave Fancher
http://davefancher.blogspot.com
"Jason Pettys" <pettys@.nospam.nospam> wrote in message
news:5A538496-BA9D-4D93-A90A-B11606E9653A@.microsoft.com...
> That may be an option but it will take a lot of effort compared with File
> Send > Page by E-mail. I don't know that the HTML of the page can be
> grabbed
> into a string like you suggest because it's a bunch of ASP.NET controls
> that
> make up a timesheet entry/report page. The timesheet entry page is also
> the
> timesheet report page by means of polymorphism to generate the correct
> data
> controls (eg, textbox or label) depending on whether the timesheet is
> editable. This is really slick because there's only one place to make
> changes when modifying what a timesheet is.
> Is there a way to grab the HTML that an arbitrary ASP.NET page will
> generate? I tried HtmlForm.InnerText and .InnerHtml but that throws an
> HttpException: "Cannot get inner content of FormActiveJobs because the
> contents are not literal." I think that's a short description of what I'm
> trying to explain in the above paragraph.
> I think to do what you suggest I'd have to write a brand new view on the
> timesheet data that can just dump HTML as a string. But that introduces
> duplication that will have ongoing maintenance costs. I'd rather find a
> way
> to hack the __VIEWSTATE so it doesn't show up.
> If you know of a way to grab the HTML an arbitrary ASP.NET page will
> generate into a string or stream I'd like to know of it.
> Jason
>
> "Dave Fancher" wrote:
>> Have you considered a server side solution that generates an e-mail wth
>> the
>> BodyFormat property of your MailMessage set to MailFormat.Html?
>> Obviously I
>> am not familiar with your project but typically when someone wants to
>> e-mail
>> a page, it's a report or flyer of some sort which is dynamically
>> generated.
>>
>> If this is the case, you may want to switch to a method that generates
>> the
>> HTML and puts it in a PlaceHolder for the page output and can also be set
>> as
>> the Body property of your MailMessage.
>>
>> HTH
>>
>> --
>> Dave Fancher
>> http://davefancher.blogspot.com
>>
>>
>> "Jason Pettys" <pettys@.nospam.nospam> wrote in message
>> news:355837CC-7A79-4163-83D8-B62A9D1EEEC2@.microsoft.com...
>> >I have an ASP.NET page that my client wants to e-mail. So in IE we
>> >choose
>> > File > Send > Page by E-mail, which opens up either Outlook or Outlook
>> > Express with the HTML page content as the message body.
>>> > EXCEPT one nasty detail is that in the e-mail client, <input
>> > type="hidden">
>> > elements are rendered as text boxes, which the __VIEWSTATE is one of,
>> > and
>> > so
>> > the viewstate is displayed in a textbox at the top of the e-mail.
>>> > I've figured out some overrides and stuff to ensure that the textbox is
>> > empty, so the HTML renders
>>> > <input type="hidden" name="__VIEWSTATE" value="">
>>> > but this still displays an empty TextBox.
>>> > Is there any way to prevent the HTML element from being written at all?
>> > I
>> > found an interesting explanation of why it's hard at this address:
>> > http://scottonwriting.net/sowblog/posts/1608.aspx
>>> > But couldn't translate that into a solution.
>>> > --
>> > Jason
>> > www.pettysconsulting.com
>>>
>>
>
Hello Jason,
If you put an asp:Button on the page, and contain the content you wish to
have rendered in a panel, something like this will do the trick (Im using
this exact technique to email portions of a site):
StringBuilder sb = new StringBuilder();
using (StringWriter sw = new StringWriter(sb))
using (HtmlTextWriter writer = new Html32TextWriter(sw))
{
theContentPanel.RenderControl(writer);
}
// at this point sb.ToString() contains a string of everything in that panel.
You're free to send this off via email or whatever.
I hope this is what you were after.
--
Matt Berther
http://www.mattberther.com
> That may be an option but it will take a lot of effort compared with
> File >
Send>> Page by E-mail. I don't know that the HTML of the page can be
Send>> grabbed
Send>>
> into a string like you suggest because it's a bunch of ASP.NET
> controls that make up a timesheet entry/report page. The timesheet
> entry page is also the timesheet report page by means of polymorphism
> to generate the correct data controls (eg, textbox or label)
> depending on whether the timesheet is editable. This is really slick
> because there's only one place to make changes when modifying what a
> timesheet is.
> Is there a way to grab the HTML that an arbitrary ASP.NET page will
> generate? I tried HtmlForm.InnerText and .InnerHtml but that throws
> an HttpException: "Cannot get inner content of FormActiveJobs because
> the contents are not literal." I think that's a short description of
> what I'm trying to explain in the above paragraph.
> I think to do what you suggest I'd have to write a brand new view on
> the timesheet data that can just dump HTML as a string. But that
> introduces duplication that will have ongoing maintenance costs. I'd
> rather find a way to hack the __VIEWSTATE so it doesn't show up.
> If you know of a way to grab the HTML an arbitrary ASP.NET page will
> generate into a string or stream I'd like to know of it.
> Jason
> "Dave Fancher" wrote:
>> Have you considered a server side solution that generates an e-mail
>> wth the BodyFormat property of your MailMessage set to
>> MailFormat.Html? Obviously I am not familiar with your project but
>> typically when someone wants to e-mail a page, it's a report or flyer
>> of some sort which is dynamically generated.
>>
>> If this is the case, you may want to switch to a method that
>> generates the HTML and puts it in a PlaceHolder for the page output
>> and can also be set as the Body property of your MailMessage.
>>
>> HTH
>>
>> --
>> Dave Fancher
>> http://davefancher.blogspot.com
>> "Jason Pettys" <pettys@.nospam.nospam> wrote in message
>> news:355837CC-7A79-4163-83D8-B62A9D1EEEC2@.microsoft.com...
>>
>>> I have an ASP.NET page that my client wants to e-mail. So in IE we
>>> choose File > Send > Page by E-mail, which opens up either Outlook
>>> or Outlook Express with the HTML page content as the message body.
>>>
>>> EXCEPT one nasty detail is that in the e-mail client, <input
>>> type="hidden">
>>> elements are rendered as text boxes, which the __VIEWSTATE is one
>>> of, and
>>> so
>>> the viewstate is displayed in a textbox at the top of the e-mail.
>>> I've figured out some overrides and stuff to ensure that the textbox
>>> is empty, so the HTML renders
>>>
>>> <input type="hidden" name="__VIEWSTATE" value="">
>>>
>>> but this still displays an empty TextBox.
>>>
>>> Is there any way to prevent the HTML element from being written at
>>> all? I found an interesting explanation of why it's hard at this
>>> address: http://scottonwriting.net/sowblog/posts/1608.aspx
>>>
>>> But couldn't translate that into a solution.
>>>
>>> --
>>> Jason
>>> www.pettysconsulting.com
The code below was a wild guess (a worth trying thing). It copies the
content properly but doesn't render the html in the mail message.
Sorry!
--
Dave Fancher
http://davefancher.blogspot.com
"Dave Fancher" <eijitek@.comcast.net> wrote in message
news:mqmdnc-FLeIVInXcRVn-rw@.comcast.com...
>I was afraid you were going to say that ;) I'm not sure of a way to grab
>the HTML before it has been rendered but since you may be able to get away
>with a different type of client side solution.
> On your read only view you could add a button to open a new window and
> dynamically populate the contents with JavaScript. I have included some
> sample code below. Basically, just wrap everything you want to include on
> the page you want to e-mail in a <span> and dynamically write the contents
> to the new window. If the areas you want to e-mail are non-linear you
> could use the getElementsByTagName() or getElementsByName() functions
> instead. You said that your client is using IE so this should work just
> fine. Keep in mind that JavaScript must be enabled.
> <script language="javascript">
> function OpenEMailWindow() {
> var newWindow = window.open("about:blank", "EMailWindow");
> newWindow.document.write("<html><head><title>EMail Sample</title><link
> rel=\"stylesheet\" href=\"styles\/default.css\"></head><body>");
> newWindow.document.write(document.getElementById("EMailableContent").innerHTML);
> newWindow.document.write("</body></html>");
> }
> </script>
> ...
> <span id="EMailableContent">
> All of your e-mailable contents would go here. Clicking the button below
> will copy <b>everything</b> in this block to be copied to the new window.
> </span>
> <input type="button" value="EMail Friendly" onclick="OpenEMailWindow();">
> ...
> HTH
> --
> Dave Fancher
> http://davefancher.blogspot.com
>
> "Jason Pettys" <pettys@.nospam.nospam> wrote in message
> news:5A538496-BA9D-4D93-A90A-B11606E9653A@.microsoft.com...
>> That may be an option but it will take a lot of effort compared with File
>>> Send > Page by E-mail. I don't know that the HTML of the page can be
>> grabbed
>> into a string like you suggest because it's a bunch of ASP.NET controls
>> that
>> make up a timesheet entry/report page. The timesheet entry page is also
>> the
>> timesheet report page by means of polymorphism to generate the correct
>> data
>> controls (eg, textbox or label) depending on whether the timesheet is
>> editable. This is really slick because there's only one place to make
>> changes when modifying what a timesheet is.
>>
>> Is there a way to grab the HTML that an arbitrary ASP.NET page will
>> generate? I tried HtmlForm.InnerText and .InnerHtml but that throws an
>> HttpException: "Cannot get inner content of FormActiveJobs because the
>> contents are not literal." I think that's a short description of what
>> I'm
>> trying to explain in the above paragraph.
>>
>> I think to do what you suggest I'd have to write a brand new view on the
>> timesheet data that can just dump HTML as a string. But that introduces
>> duplication that will have ongoing maintenance costs. I'd rather find a
>> way
>> to hack the __VIEWSTATE so it doesn't show up.
>>
>> If you know of a way to grab the HTML an arbitrary ASP.NET page will
>> generate into a string or stream I'd like to know of it.
>>
>> Jason
>>
>>
>>
>> "Dave Fancher" wrote:
>>
>>> Have you considered a server side solution that generates an e-mail wth
>>> the
>>> BodyFormat property of your MailMessage set to MailFormat.Html?
>>> Obviously I
>>> am not familiar with your project but typically when someone wants to
>>> e-mail
>>> a page, it's a report or flyer of some sort which is dynamically
>>> generated.
>>>
>>> If this is the case, you may want to switch to a method that generates
>>> the
>>> HTML and puts it in a PlaceHolder for the page output and can also be
>>> set as
>>> the Body property of your MailMessage.
>>>
>>> HTH
>>>
>>> --
>>> Dave Fancher
>>> http://davefancher.blogspot.com
>>>
>>>
>>> "Jason Pettys" <pettys@.nospam.nospam> wrote in message
>>> news:355837CC-7A79-4163-83D8-B62A9D1EEEC2@.microsoft.com...
>>> >I have an ASP.NET page that my client wants to e-mail. So in IE we
>>> >choose
>>> > File > Send > Page by E-mail, which opens up either Outlook or Outlook
>>> > Express with the HTML page content as the message body.
>>>>> > EXCEPT one nasty detail is that in the e-mail client, <input
>>> > type="hidden">
>>> > elements are rendered as text boxes, which the __VIEWSTATE is one of,
>>> > and
>>> > so
>>> > the viewstate is displayed in a textbox at the top of the e-mail.
>>>>> > I've figured out some overrides and stuff to ensure that the textbox
>>> > is
>>> > empty, so the HTML renders
>>>>> > <input type="hidden" name="__VIEWSTATE" value="">
>>>>> > but this still displays an empty TextBox.
>>>>> > Is there any way to prevent the HTML element from being written at
>>> > all? I
>>> > found an interesting explanation of why it's hard at this address:
>>> > http://scottonwriting.net/sowblog/posts/1608.aspx
>>>>> > But couldn't translate that into a solution.
>>>>> > --
>>> > Jason
>>> > www.pettysconsulting.com
>>>>>
>>>
>>>
Hi Jason,
I think Matt's suggestion on using the STringBuilder and HtmlTextWriter to
intercept the asp.net server control's output html is reasonable. In fact,
we can use this means to also get the HtmlForm or other control's output
html in a stringbuilder. Then, we can do some modification as we want, such
as remove all the <input type="hidden" ..> element or replace them with
other elements in it.... After that, you can just insert the modified
html string into your email body.
If there is any other questions or concerns, please feel free to post here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Thanks Matt and Steven! That is doing the trick.
Jason
www.pettysconsulting.com
"Steven Cheng[MSFT]" wrote:
> Hi Jason,
> I think Matt's suggestion on using the STringBuilder and HtmlTextWriter to
> intercept the asp.net server control's output html is reasonable. In fact,
> we can use this means to also get the HtmlForm or other control's output
> html in a stringbuilder. Then, we can do some modification as we want, such
> as remove all the <input type="hidden" ..> element or replace them with
> other elements in it.... After that, you can just insert the modified
> html string into your email body.
> If there is any other questions or concerns, please feel free to post here.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
You're welcome.
Have a good day!
Regards,
Steven Cheng
Microsoft Online Support
Suppress viewstate __viewstate rendering
File > Send > Page by E-mail, which opens up either Outlook or Outlook
Express with the HTML page content as the message body.
EXCEPT one nasty detail is that in the e-mail client, <input type="hidden">
elements are rendered as text boxes, which the __VIEWSTATE is one of, and so
the viewstate is displayed in a textbox at the top of the e-mail.
I've figured out some overrides and stuff to ensure that the textbox is
empty, so the HTML renders
<input type="hidden" name="__VIEWSTATE" value="">
but this still displays an empty TextBox.
Is there any way to prevent the HTML element from being written at all? I
found an interesting explanation of why it's hard at this address:
http://scottonwriting.net/sowblog/posts/1608.aspx
But couldn't translate that into a solution.
Jason
www.pettysconsulting.comJust a thought
Is there way to set style display as none for hidden variable '
vinay
"Jason Pettys" wrote:
> I have an ASP.NET page that my client wants to e-mail. So in IE we choose
> File > Send > Page by E-mail, which opens up either Outlook or Outlook
> Express with the HTML page content as the message body.
> EXCEPT one nasty detail is that in the e-mail client, <input type="hidden"
> elements are rendered as text boxes, which the __VIEWSTATE is one of, and
so
> the viewstate is displayed in a textbox at the top of the e-mail.
> I've figured out some overrides and stuff to ensure that the textbox is
> empty, so the HTML renders
> <input type="hidden" name="__VIEWSTATE" value="">
> but this still displays an empty TextBox.
> Is there any way to prevent the HTML element from being written at all? I
> found an interesting explanation of why it's hard at this address:
> http://scottonwriting.net/sowblog/posts/1608.aspx
> But couldn't translate that into a solution.
> --
> Jason
> www.pettysconsulting.com
>
I tried your suggestion but it did not work. See
http://pettysconsulting.com/test.htm. It has this defined:
<style type="text/css">
input { font-family: Verdana; display: none; }
</style>
Neither type="text" nor type="hidden" elements are shown in the web page,
but both are shown in Outlook (with Verdana font).
"vinay" wrote:
> Just a thought
> Is there way to set style display as none for hidden variable '
> vinay
> "Jason Pettys" wrote:
>
Have you considered a server side solution that generates an e-mail wth the
BodyFormat property of your MailMessage set to MailFormat.Html? Obviously I
am not familiar with your project but typically when someone wants to e-mail
a page, it's a report or flyer of some sort which is dynamically generated.
If this is the case, you may want to switch to a method that generates the
HTML and puts it in a PlaceHolder for the page output and can also be set as
the Body property of your MailMessage.
HTH
Dave Fancher
http://davefancher.blogspot.com
"Jason Pettys" <pettys@.nospam.nospam> wrote in message
news:355837CC-7A79-4163-83D8-B62A9D1EEEC2@.microsoft.com...
>I have an ASP.NET page that my client wants to e-mail. So in IE we choose
> File > Send > Page by E-mail, which opens up either Outlook or Outlook
> Express with the HTML page content as the message body.
> EXCEPT one nasty detail is that in the e-mail client, <input
> type="hidden">
> elements are rendered as text boxes, which the __VIEWSTATE is one of, and
> so
> the viewstate is displayed in a textbox at the top of the e-mail.
> I've figured out some overrides and stuff to ensure that the textbox is
> empty, so the HTML renders
> <input type="hidden" name="__VIEWSTATE" value="">
> but this still displays an empty TextBox.
> Is there any way to prevent the HTML element from being written at all? I
> found an interesting explanation of why it's hard at this address:
> http://scottonwriting.net/sowblog/posts/1608.aspx
> But couldn't translate that into a solution.
> --
> Jason
> www.pettysconsulting.com
>
That may be an option but it will take a lot of effort compared with File >
Send > Page by E-mail. I don't know that the HTML of the page can be grabbe
d
into a string like you suggest because it's a bunch of ASP.NET controls that
make up a timesheet entry/report page. The timesheet entry page is also the
timesheet report page by means of polymorphism to generate the correct data
controls (eg, textbox or label) depending on whether the timesheet is
editable. This is really slick because there's only one place to make
changes when modifying what a timesheet is.
Is there a way to grab the HTML that an arbitrary ASP.NET page will
generate? I tried HtmlForm.InnerText and .InnerHtml but that throws an
HttpException: "Cannot get inner content of FormActiveJobs because the
contents are not literal." I think that's a short description of what I'm
trying to explain in the above paragraph.
I think to do what you suggest I'd have to write a brand new view on the
timesheet data that can just dump HTML as a string. But that introduces
duplication that will have ongoing maintenance costs. I'd rather find a way
to hack the __VIEWSTATE so it doesn't show up.
If you know of a way to grab the HTML an arbitrary ASP.NET page will
generate into a string or stream I'd like to know of it.
Jason
"Dave Fancher" wrote:
> Have you considered a server side solution that generates an e-mail wth th
e
> BodyFormat property of your MailMessage set to MailFormat.Html? Obviously
I
> am not familiar with your project but typically when someone wants to e-ma
il
> a page, it's a report or flyer of some sort which is dynamically generated
.
> If this is the case, you may want to switch to a method that generates the
> HTML and puts it in a PlaceHolder for the page output and can also be set
as
> the Body property of your MailMessage.
> HTH
> --
> Dave Fancher
> http://davefancher.blogspot.com
>
> "Jason Pettys" <pettys@.nospam.nospam> wrote in message
> news:355837CC-7A79-4163-83D8-B62A9D1EEEC2@.microsoft.com...
>
>
I was afraid you were going to say that ;) I'm not sure of a way to grab
the HTML before it has been rendered but since you may be able to get away
with a different type of client side solution.
On your read only view you could add a button to open a new window and
dynamically populate the contents with JavaScript. I have included some
sample code below. Basically, just wrap everything you want to include on
the page you want to e-mail in a <span> and dynamically write the contents
to the new window. If the areas you want to e-mail are non-linear you could
use the getElementsByTagName() or getElementsByName() functions instead.
You said that your client is using IE so this should work just fine. Keep
in mind that JavaScript must be enabled.
<script language="javascript">
function OpenEMailWindow() {
var newWindow = window.open("about :blank", "EMailWindow");
newWindow.document.write("<html><head><title>EMail Sample</title><link
rel=\"stylesheet\" href=\"styles\/default.css\"></head><body>");
newWindow.document.write(document.getElementById("EMailableContent").innerHT
ML);
newWindow.document.write("</body></html>");
}
</script>
...
<span id="EMailableContent">
All of your e-mailable contents would go here. Clicking the button below
will copy <b>everything</b> in this block to be copied to the new window.
</span>
<input type="button" value="EMail Friendly" onclick="OpenEMailWindow();">
...
HTH
--
Dave Fancher
http://davefancher.blogspot.com
"Jason Pettys" <pettys@.nospam.nospam> wrote in message
news:5A538496-BA9D-4D93-A90A-B11606E9653A@.microsoft.com...
> That may be an option but it will take a lot of effort compared with File
> Send > Page by E-mail. I don't know that the HTML of the page can be
> grabbed
> into a string like you suggest because it's a bunch of ASP.NET controls
> that
> make up a timesheet entry/report page. The timesheet entry page is also
> the
> timesheet report page by means of polymorphism to generate the correct
> data
> controls (eg, textbox or label) depending on whether the timesheet is
> editable. This is really slick because there's only one place to make
> changes when modifying what a timesheet is.
> Is there a way to grab the HTML that an arbitrary ASP.NET page will
> generate? I tried HtmlForm.InnerText and .InnerHtml but that throws an
> HttpException: "Cannot get inner content of FormActiveJobs because the
> contents are not literal." I think that's a short description of what I'm
> trying to explain in the above paragraph.
> I think to do what you suggest I'd have to write a brand new view on the
> timesheet data that can just dump HTML as a string. But that introduces
> duplication that will have ongoing maintenance costs. I'd rather find a
> way
> to hack the __VIEWSTATE so it doesn't show up.
> If you know of a way to grab the HTML an arbitrary ASP.NET page will
> generate into a string or stream I'd like to know of it.
> Jason
>
> "Dave Fancher" wrote:
>
Hello Jason,
If you put an asp:Button on the page, and contain the content you wish to
have rendered in a panel, something like this will do the trick (Im using
this exact technique to email portions of a site):
StringBuilder sb = new StringBuilder();
using (StringWriter sw = new StringWriter(sb))
using (HtmlTextWriter writer = new Html32TextWriter(sw))
{
theContentPanel.RenderControl(writer);
}
// at this point sb.ToString() contains a string of everything in that panel
.
You're free to send this off via email or whatever.
I hope this is what you were after.
Matt Berther
http://www.mattberther.com
> That may be an option but it will take a lot of effort compared with
> File >
>
Send>> Page by E-mail. I don't know that the HTML of the page can be
Send>> grabbed
Send>>
> into a string like you suggest because it's a bunch of ASP.NET
> controls that make up a timesheet entry/report page. The timesheet
> entry page is also the timesheet report page by means of polymorphism
> to generate the correct data controls (eg, textbox or label)
> depending on whether the timesheet is editable. This is really slick
> because there's only one place to make changes when modifying what a
> timesheet is.
> Is there a way to grab the HTML that an arbitrary ASP.NET page will
> generate? I tried HtmlForm.InnerText and .InnerHtml but that throws
> an HttpException: "Cannot get inner content of FormActiveJobs because
> the contents are not literal." I think that's a short description of
> what I'm trying to explain in the above paragraph.
> I think to do what you suggest I'd have to write a brand new view on
> the timesheet data that can just dump HTML as a string. But that
> introduces duplication that will have ongoing maintenance costs. I'd
> rather find a way to hack the __VIEWSTATE so it doesn't show up.
> If you know of a way to grab the HTML an arbitrary ASP.NET page will
> generate into a string or stream I'd like to know of it.
> Jason
> "Dave Fancher" wrote:
>
The code below was a wild guess (a worth trying thing). It copies the
content properly but doesn't render the html in the mail message.
Sorry!
--
Dave Fancher
http://davefancher.blogspot.com
"Dave Fancher" <eijitek@.comcast.net> wrote in message
news:mqmdnc-FLeIVInXcRVn-rw@.comcast.com...
>I was afraid you were going to say that ;) I'm not sure of a way to grab
>the HTML before it has been rendered but since you may be able to get away
>with a different type of client side solution.
> On your read only view you could add a button to open a new window and
> dynamically populate the contents with JavaScript. I have included some
> sample code below. Basically, just wrap everything you want to include on
> the page you want to e-mail in a <span> and dynamically write the contents
> to the new window. If the areas you want to e-mail are non-linear you
> could use the getElementsByTagName() or getElementsByName() functions
> instead. You said that your client is using IE so this should work just
> fine. Keep in mind that JavaScript must be enabled.
> <script language="javascript">
> function OpenEMailWindow() {
> var newWindow = window.open("about :blank", "EMailWindow");
> newWindow.document.write("<html><head><title>EMail Sample</title><link
> rel=\"stylesheet\" href=\"styles\/default.css\"></head><body>");
> newWindow.document.write(document.getElementById("EMailableContent").inner
HTML);
> newWindow.document.write("</body></html>");
> }
> </script>
> ...
> <span id="EMailableContent">
> All of your e-mailable contents would go here. Clicking the button below
> will copy <b>everything</b> in this block to be copied to the new window.
> </span>
> <input type="button" value="EMail Friendly" onclick="OpenEMailWindow();">
> ...
> HTH
> --
> Dave Fancher
> http://davefancher.blogspot.com
>
> "Jason Pettys" <pettys@.nospam.nospam> wrote in message
> news:5A538496-BA9D-4D93-A90A-B11606E9653A@.microsoft.com...
>
Hi Jason,
I think Matt's suggestion on using the STringBuilder and HtmlTextWriter to
intercept the asp.net server control's output html is reasonable. In fact,
we can use this means to also get the HtmlForm or other control's output
html in a stringbuilder. Then, we can do some modification as we want, such
as remove all the <input type="hidden" ..> element or replace them with
other elements in it.... After that, you can just insert the modified
html string into your email body.
If there is any other questions or concerns, please feel free to post here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Thanks Matt and Steven! That is doing the trick.
Jason
www.pettysconsulting.com
"Steven Cheng[MSFT]" wrote:
> Hi Jason,
> I think Matt's suggestion on using the STringBuilder and HtmlTextWriter to
> intercept the asp.net server control's output html is reasonable. In fact,
> we can use this means to also get the HtmlForm or other control's output
> html in a stringbuilder. Then, we can do some modification as we want, suc
h
> as remove all the <input type="hidden" ..> element or replace them with
> other elements in it.... After that, you can just insert the modified
> html string into your email body.
> If there is any other questions or concerns, please feel free to post here
.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
Suppressing the URL in a asp.net app
I've seen many Internet sites that suppress the URL or show the same URL all
the time your moving around different pages. You'll only see the real page
with it's path in the statusbar way down on the page.
How is that done in asp.net?
I have an example on this, in sweden, stockholm where I live we have a
wellknown kindergarten for older men (warehouse shop) named Clas Ohlson
http://www.clasohlson.se/
You'll also have them on a flaglink in finnish, norwegian and english
language just above the statusbar. So that you see what I mean.
Any ideas?
TIA
Kenneth PThe above link (http://www.clasohlson.se/) is using a frameset. The
address bar isn't updated since you're navigating within a frame of the
page frameset.
Since HTML Framesets are a client side technology, this approach would
work the exact same in ASP.NET.
More info on frames here:
http://www.w3schools.com/html/html_frames.asp
- Jon
http://weblogs.asp.net/jgalloway
Hi
They are using frames. Just look at the main page "View -> Sourece" and you
will see that page have some frame.
With right click on page you'll see that page has url. Click on top and also
on bottom to see that the page url is different.
Also take a look on frame stuff to undestand clearly what is happening.
There is no trick made in asp.net in that page.
Cheers.
"Kenneth P" wrote:
> Hi,
> I've seen many Internet sites that suppress the URL or show the same URL all
> the time your moving around different pages. You'll only see the real page
> with it's path in the statusbar way down on the page.
> How is that done in asp.net?
> I have an example on this, in sweden, stockholm where I live we have a
> wellknown kindergarten for older men (warehouse shop) named Clas Ohlson
> http://www.clasohlson.se/
> You'll also have them on a flaglink in finnish, norwegian and english
> language just above the statusbar. So that you see what I mean.
> Any ideas?
> TIA
> Kenneth P
Kenneth P wrote:
> Hi,
> I've seen many Internet sites that suppress the URL or show the same
> URL all the time your moving around different pages. You'll only see
> the real page with it's path in the statusbar way down on the page.
> How is that done in asp.net?
> I have an example on this, in sweden, stockholm where I live we have a
> wellknown kindergarten for older men (warehouse shop) named Clas
> Ohlson
> http://www.clasohlson.se/
> You'll also have them on a flaglink in finnish, norwegian and english
> language just above the statusbar. So that you see what I mean.
> Any ideas?
> TIA
> Kenneth P
That has nothing to do with asp.net or any other server-side technology,
it is client-side html.
The trick is to use a frameset as your first page. The URL shown is the url of that
frameset definition, the rest of the site works within that frameset.
For that site: use "View | Source" from the menu and scroll down to below the
<NOSCRIPT> section. (strange, a noscript section with embedded javascript...)
Hans Kesting
Hi jongalloway,
Hmmm...
Have you seen the same technology on pages without frames?
Kenneth P
"jongalloway" wrote:
> The above link (http://www.clasohlson.se/) is using a frameset. The
> address bar isn't updated since you're navigating within a frame of the
> page frameset.
> Since HTML Framesets are a client side technology, this approach would
> work the exact same in ASP.NET.
> More info on frames here:
> http://www.w3schools.com/html/html_frames.asp
> - Jon
> http://weblogs.asp.net/jgalloway
>
"Kenneth P" wrote:
> Hi jongalloway,
> Hmmm...
> Have you seen the same technology on pages without frames?
> Kenneth P
>
> "jongalloway" wrote:
> > The above link (http://www.clasohlson.se/) is using a frameset. The
> > address bar isn't updated since you're navigating within a frame of the
> > page frameset.
> > Since HTML Framesets are a client side technology, this approach would
> > work the exact same in ASP.NET.
> > More info on frames here:
> > http://www.w3schools.com/html/html_frames.asp
> > - Jon
> > http://weblogs.asp.net/jgalloway
Sorry about that empty post above, accidentally hit the Enter key :-)
here are some interesting articles that could solve your problem:
www.15seconds.com/issue/030522.htm
www.codeproject.com/aspnet/URLRewriter.asp
I hope this helps
"Tim Bens" wrote:
>
> "Kenneth P" wrote:
> > Hi jongalloway,
> > Hmmm...
> > Have you seen the same technology on pages without frames?
> > Kenneth P
> > "jongalloway" wrote:
> > > The above link (http://www.clasohlson.se/) is using a frameset. The
> > > address bar isn't updated since you're navigating within a frame of the
> > > page frameset.
> > > > Since HTML Framesets are a client side technology, this approach would
> > > work the exact same in ASP.NET.
> > > > More info on frames here:
> > > http://www.w3schools.com/html/html_frames.asp
> > > - Jon
> > > http://weblogs.asp.net/jgalloway
> >
Tim,
Thanks for the links.
Kenneth P
"Tim Bens" wrote:
> Sorry about that empty post above, accidentally hit the Enter key :-)
> here are some interesting articles that could solve your problem:
> www.15seconds.com/issue/030522.htm
> www.codeproject.com/aspnet/URLRewriter.asp
> I hope this helps
>
> "Tim Bens" wrote:
> > "Kenneth P" wrote:
> > > Hi jongalloway,
> > > > Hmmm...
> > > > Have you seen the same technology on pages without frames?
> > > > Kenneth P
> > > > > "jongalloway" wrote:
> > > > > The above link (http://www.clasohlson.se/) is using a frameset. The
> > > > address bar isn't updated since you're navigating within a frame of the
> > > > page frameset.
> > > > > > Since HTML Framesets are a client side technology, this approach would
> > > > work the exact same in ASP.NET.
> > > > > > More info on frames here:
> > > > http://www.w3schools.com/html/html_frames.asp
> > > > - Jon
> > > > http://weblogs.asp.net/jgalloway
> > > >
Suppressing the URL in a asp.net app
I've seen many Internet sites that suppress the URL or show the same URL all
the time your moving around different pages. You'll only see the real page
with it's path in the statusbar way down on the page.
How is that done in asp.net?
I have an example on this, in sweden, stockholm where I live we have a
wellknown kindergarten for older men (warehouse shop) named Clas Ohlson
http://www.clasohlson.se/
You'll also have them on a flaglink in finnish, norwegian and english
language just above the statusbar. So that you see what I mean.
Any ideas?
TIA
Kenneth PThe above link (http://www.clasohlson.se/) is using a frameset. The
address bar isn't updated since you're navigating within a frame of the
page frameset.
Since HTML Framesets are a client side technology, this approach would
work the exact same in ASP.NET.
More info on frames here:
http://www.w3schools.com/html/html_frames.asp
- Jon
http://weblogs.asp.net/jgalloway
Hi
They are using frames. Just look at the main page "View -> Sourece" and you
will see that page have some frame.
With right click on page you'll see that page has url. Click on top and also
on bottom to see that the page url is different.
Also take a look on frame stuff to undestand clearly what is happening.
There is no trick made in asp.net in that page.
Cheers.
"Kenneth P" wrote:
> Hi,
> I've seen many Internet sites that suppress the URL or show the same URL a
ll
> the time your moving around different pages. You'll only see the real page
> with it's path in the statusbar way down on the page.
> How is that done in asp.net?
> I have an example on this, in sweden, stockholm where I live we have a
> wellknown kindergarten for older men (warehouse shop) named Clas Ohlson
> http://www.clasohlson.se/
> You'll also have them on a flaglink in finnish, norwegian and english
> language just above the statusbar. So that you see what I mean.
> Any ideas?
> TIA
> Kenneth P
Kenneth P wrote:
> Hi,
> I've seen many Internet sites that suppress the URL or show the same
> URL all the time your moving around different pages. You'll only see
> the real page with it's path in the statusbar way down on the page.
> How is that done in asp.net?
> I have an example on this, in sweden, stockholm where I live we have a
> wellknown kindergarten for older men (warehouse shop) named Clas
> Ohlson
> http://www.clasohlson.se/
> You'll also have them on a flaglink in finnish, norwegian and english
> language just above the statusbar. So that you see what I mean.
> Any ideas?
> TIA
> Kenneth P
That has nothing to do with asp.net or any other server-side technology,
it is client-side html.
The trick is to use a frameset as your first page. The URL shown is the url
of that
frameset definition, the rest of the site works within that frameset.
For that site: use "View | Source" from the menu and scroll down to below th
e
<NOSCRIPT> section. (strange, a noscript section with embedded javascript...
)
Hans Kesting
Hi jongalloway,
Hmmm...
Have you seen the same technology on pages without frames?
Kenneth P
"jongalloway" wrote:
> The above link (http://www.clasohlson.se/) is using a frameset. The
> address bar isn't updated since you're navigating within a frame of the
> page frameset.
> Since HTML Framesets are a client side technology, this approach would
> work the exact same in ASP.NET.
> More info on frames here:
> http://www.w3schools.com/html/html_frames.asp
> - Jon
> http://weblogs.asp.net/jgalloway
>
"Kenneth P" wrote:
> Hi jongalloway,
> Hmmm...
> Have you seen the same technology on pages without frames?
> Kenneth P
>
> "jongalloway" wrote:
>
Sorry about that empty post above, accidentally hit the Enter key :-)
here are some interesting articles that could solve your problem:
www.15seconds.com/issue/030522.htm
www.codeproject.com/aspnet/URLRewriter.asp
I hope this helps
"Tim Bens" wrote:
>
> "Kenneth P" wrote:
>
Tim,
Thanks for the links.
Kenneth P
"Tim Bens" wrote:
> Sorry about that empty post above, accidentally hit the Enter key :-)
> here are some interesting articles that could solve your problem:
> www.15seconds.com/issue/030522.htm
> www.codeproject.com/aspnet/URLRewriter.asp
> I hope this helps
>
> "Tim Bens" wrote:
>