Showing posts with label custom. Show all posts
Showing posts with label custom. Show all posts

Saturday, March 31, 2012

submitting form values

Hi all, (fyi, I know ASP well, .NET is new)

ok, submitting a form. Few things:

1. the form is a custom collage of textboxes, no formview, no detailsview, just textboxes, dropdownlists, and datavalidators.

2. The form get populated via querystring'd 'UserID' as so:---------------

Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim strSQL As String
Dim myDataReader As OleDbDataReader

Session.Item("CurrentUserIDtoEdit") = Request.QueryString("UserID")

strSQL = "SELECT * FROM Users " _
& "WHERE uniqueid='" & Session.Item("CurrentUserIDtoEdit") & "'"

myConnection = New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("strConn"))

myCommand = New OleDbCommand(strSQL, myConnection)

myConnection.Open()
myDataReader = myCommand.ExecuteReader()
Do While (myDataReader.Read())
TextboxFirstName.Text = Convert.ToString(myDataReader("FirstName"))
TextboxLastName.Text = Convert.ToString(myDataReader("LastName"))
TextboxAddress1.Text = Convert.ToString(myDataReader("Address1"))
TextboxAddress2.Text = Convert.ToString(myDataReader("Address2"))
TextboxCity.Text = Convert.ToString(myDataReader("City"))
DropDownState.SelectedValue = Convert.ToString(myDataReader("State"))
TextBoxZipCode.Text = Convert.ToString(myDataReader("Zip"))
TextBoxPhone.Text = Convert.ToString(myDataReader("Phone"))
TextBoxEmail.Text = Convert.ToString(myDataReader("emailaddress"))
TextboxUsername.Text = Convert.ToString(myDataReader("Username"))
TextboxPassword.Text = Convert.ToString(myDataReader("Password"))
DropDownListPermissionLevel.SelectedValue = myDataReader("PermissionLevel")
CheckBoxDeleted.Checked = Convert.ToBoolean(myDataReader("Deleted"))
Loop
myDataReader.Close()
myConnection.Close()

--------------THIS WORKS GREAT

Question is, this page is a 'Modify User' page. What I want is it to populate with current 'User' data from the DB (that's working fine. as above)

AND, when resubmitted, update the DB with the new data from the form, show a 'success label' of some sort with a minor delay, and response.redirect to 'Menu.aspx'

isPostBack is an option, yes...but how to integrate that conditional coding with a SQLDataObject? or do I hard code the update like the above code...and how?

(I have the Stored Procedure as follows)----------

CREATE PROCEDURE dbo.UpdateUser
(
@dotnet.itags.org.UniqueID int,
@dotnet.itags.org.FirstName nvarchar(50),
@dotnet.itags.org.LastName nvarchar(50),
@dotnet.itags.org.Address1 nvarchar(100),
@dotnet.itags.org.Address2 nvarchar(100),
@dotnet.itags.org.City char(100),
@dotnet.itags.org.State char(2),
@dotnet.itags.org.Zip char(5),
@dotnet.itags.org.Phone char(10),
@dotnet.itags.org.emailaddress nvarchar(100),
@dotnet.itags.org.Username nvarchar(50),
@dotnet.itags.org.Password nvarchar(50),
@dotnet.itags.org.PermissionLevel char(1),
@dotnet.itags.org.Deleted bit,
@dotnet.itags.org.SystemUserID int

)
AS
SET NOCOUNT OFF;
UPDATE Users
SET
FirstName = @dotnet.itags.org.FirstName,
LastName = @dotnet.itags.org.LastName,
Address1 = @dotnet.itags.org.Address1,
Address2 = @dotnet.itags.org.Address2,
City = @dotnet.itags.org.City,
State = @dotnet.itags.org.State,
Zip = @dotnet.itags.org.Zip,
Phone = @dotnet.itags.org.Phone,
emailaddress = @dotnet.itags.org.emailaddress,
username = @dotnet.itags.org.Username,
[Password] = @dotnet.itags.org.Password,
PermissionLevel = @dotnet.itags.org.PermissionLevel,
Deleted = @dotnet.itags.org.Deleted,

LastModifiedBy = @dotnet.itags.org.SystemUserID,
LastModifiedDate = CURRENT_TIMESTAMP

where Uniqueid = @dotnet.itags.org.UniqueID
GO

-----------

Do I somehow, link the SQLDataobject with the 'onclick' event of the 'submit' button?

NOTE: I figured out that the SQLDataobject has an updatecommandtype and an updatequery property panel where I set the params for the SP correctly to the form vars and session.items so it's ready to go...

---

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ProductionConnectionString %>"
InsertCommand="InsertUser" InsertCommandType="StoredProcedure" SelectCommand="GetUser"
SelectCommandType="StoredProcedure" UpdateCommand="UpdateUser" UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:SessionParameter Name="UniqueID" SessionField="CurrentUserIDtoEdit" Type="Int32" />
<asp:ControlParameter ControlID="TextboxFirstName" Name="FirstName" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxLastName" Name="LastName" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxAddress1" Name="Address1" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxAddress2" Name="Address2" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxCity" Name="City" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="DropDownState" Name="State" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="TextBoxZipCode" Name="Zip" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="TextBoxPhone" Name="Phone" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="TextBoxEmail" Name="emailaddress" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxUsername" Name="Username" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="TextboxPassword" Name="Password" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="DropDownListPermissionLevel" Name="PermissionLevel"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="CheckBoxDeleted" Name="Deleted" PropertyName="Checked"
Type="Boolean" />
<asp:SessionParameter Name="SystemUserID" SessionField="UserID" Type="Int32" />
<asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:QueryStringParameter DefaultValue="" Name="UserID" QueryStringField="UserID"
Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="Address1" Type="String" />
<asp:Parameter Name="Address2" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="Zip" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="Fax" Type="String" />
<asp:Parameter Name="emailaddress" Type="String" />
<asp:Parameter Name="Username" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter Name="PermissionLevel" Type="String" />
<asp:Parameter Name="CurrentUserID" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
<table>
<tr>
<td colspan="3" align="left"><asp:Label ID="Label1" runat="server" Text="Modify User" Font-Size="Large"></asp:Label></td>
</tr>
<tr>
<td style="height: 24px">First Name</td>
<td style="height: 24px"><asp:TextBox ID="TextboxFirstName" runat="server"></asp:TextBox></td>
<td style="height: 24px"><asp:RequiredFieldValidator ID="RequiredFieldValidatorFirstName" runat="server" ControlToValidate="TextboxFirstName"
ErrorMessage="First Name Required"></asp:RequiredFieldValidator> </td>
</tr>
<tr>
<td>Last Name</td>
<td><asp:TextBox ID="TextboxLastName" runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidatorLastName" runat="server"
ControlToValidate="TextboxLastName" ErrorMessage="Last Name Required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Address 1</td>
<td><asp:TextBox ID="TextboxAddress1" runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidatorAddress1" runat="server"
ControlToValidate="TextboxAddress1" ErrorMessage="Address Required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Address 2</td>
<td><asp:TextBox ID="TextboxAddress2" runat="server"></asp:TextBox></td>
<td></td>
</tr>
<tr>
<td>City</td>
<td><asp:TextBox ID="TextboxCity" runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldCity" runat="server"
ControlToValidate="TextboxCity" ErrorMessage="City Required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>State</td>
<td><asp:DropDownList id="DropDownState" runat="server"
<asp:ListItem Value="AL">Alabama</asp:ListItem
<asp:ListItem Value="AK">Alaska</asp:ListItem
<asp:ListItem Value="AZ">Arizona</asp:ListItem
<asp:ListItem Value="AR">Arkansas</asp:ListItem
<asp:ListItem Value="CA">California</asp:ListItem
<asp:ListItem Value="CO">Colorado</asp:ListItem
<asp:ListItem Value="CT">Connecticut</asp:ListItem
<asp:ListItem Value="DC">District of Columbia</asp:ListItem
<asp:ListItem Value="DE">Delaware</asp:ListItem
<asp:ListItem Value="FL">Florida</asp:ListItem
<asp:ListItem Value="GA">Georgia</asp:ListItem
<asp:ListItem Value="HI">Hawaii</asp:ListItem
<asp:ListItem Value="ID">Idaho</asp:ListItem
<asp:ListItem Value="IL">Illinois</asp:ListItem
<asp:ListItem Value="IN">Indiana</asp:ListItem
<asp:ListItem Value="IA">Iowa</asp:ListItem
<asp:ListItem Value="KS">Kansas</asp:ListItem
<asp:ListItem Value="KY">Kentucky</asp:ListItem
<asp:ListItem Value="LA">Louisiana</asp:ListItem
<asp:ListItem Value="ME">Maine</asp:ListItem
<asp:ListItem Value="MD">Maryland</asp:ListItem
<asp:ListItem Value="MA">Massachusetts</asp:ListItem
<asp:ListItem Value="MI">Michigan</asp:ListItem
<asp:ListItem Value="MN">Minnesota</asp:ListItem
<asp:ListItem Value="MS">Mississippi</asp:ListItem
<asp:ListItem Value="MO">Missouri</asp:ListItem
<asp:ListItem Value="MT">Montana</asp:ListItem
<asp:ListItem Value="NE">Nebraska</asp:ListItem
<asp:ListItem Value="NV">Nevada</asp:ListItem
<asp:ListItem Value="NH">New Hampshire</asp:ListItem
<asp:ListItem Value="NJ">New Jersey</asp:ListItem
<asp:ListItem Value="NM">New Mexico</asp:ListItem
<asp:ListItem Value="NY">New York</asp:ListItem
<asp:ListItem Value="NC">North Carolina</asp:ListItem
<asp:ListItem Value="ND">North Dakota</asp:ListItem
<asp:ListItem Value="OH">Ohio</asp:ListItem
<asp:ListItem Value="OK">Oklahoma</asp:ListItem
<asp:ListItem Value="OR">Oregon</asp:ListItem
<asp:ListItem Value="PA">Pennsylvania</asp:ListItem
<asp:ListItem Value="RI">Rhode Island</asp:ListItem
<asp:ListItem Value="SC">South Carolina</asp:ListItem
<asp:ListItem Value="SD">South Dakota</asp:ListItem
<asp:ListItem Value="TN">Tennessee</asp:ListItem
<asp:ListItem Value="TX">Texas</asp:ListItem
<asp:ListItem Value="UT">Utah</asp:ListItem
<asp:ListItem Value="VT">Vermont</asp:ListItem
<asp:ListItem Value="VA">Virginia</asp:ListItem
<asp:ListItem Value="WA">Washington</asp:ListItem
<asp:ListItem Value="WV">West Virginia</asp:ListItem
<asp:ListItem Value="WI">Wisconsin</asp:ListItem
<asp:ListItem Value="WY">Wyoming</asp:ListItem
</asp:DropDownList>
</td>
<td></td>
</tr>
<tr>
<td>Zip Code</td>
<td><asp:TextBox ID="TextBoxZipCode" runat="server"></asp:TextBox></td>
<td><asp:RegularExpressionValidator id="RegularExpressionValidatorZipCode" runat="server" ErrorMessage="Zip format (12345-1234) last four optional" ControlToValidate="TextBoxZipCode" ValidationExpression="\d{5}(-\d{4})?"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>Phone</td>
<td><asp:TextBox ID="TextBoxPhone" runat="server"></asp:TextBox></td>
<td><asp:RegularExpressionValidator ID="RegularExpressionValidatorPhone" runat="server" ErrorMessage="Phone Format (1234567890)" ControlToValidate="TextBoxPhone" ValidationExpression="((\(\d{3}\) ?)|(\d{3}))?\d{3}\d{4}"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>Email</td>
<td><asp:TextBox ID="TextBoxEmail" runat="server"></asp:TextBox></td>
<td><asp:RegularExpressionValidator id="RegularExpressionValidatorEmail" runat="server" ErrorMessage="Email format (a@dotnet.itags.org.a.com)" ControlToValidate="TextBoxEmail" ValidationExpression="\w+([-+.']\w+)*@dotnet.itags.org.\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>Username</td>
<td><asp:TextBox ID="TextboxUsername" runat="server"></asp:TextBox></td>
<td><asp:RegularExpressionValidator ID="RegularExpressionValidatorUsername" runat="server" ErrorMessage="Username must be 4 chars long and start with a letter." ControlToValidate="TextboxUsername" ValidationExpression="^[A-Za-z]\w{3,}$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>Password</td>
<td><asp:TextBox ID="TextboxPassword" runat="server"></asp:TextBox></td>
<td><asp:RequiredFieldValidator ID="RequiredFieldValidatorPassword" runat="server"
ControlToValidate="TextboxPassword" ErrorMessage="Password Required"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Permission Level</td>
<td><asp:DropDownList ID="DropDownListPermissionLevel" runat="server">
<asp:ListItem Selected="True">Select One...</asp:ListItem>
<asp:ListItem Value="1">Admin</asp:ListItem>
<asp:ListItem Value="2">Manager</asp:ListItem>
</asp:DropDownList></td>
<td></td>
</tr>
<tr>
<td>Deleted</td>
<td><asp:CheckBox ID="CheckBoxDeleted" runat="server" /></td>
<td></td>
</tr>

<tr><td colspan="3">
<asp:ValidationSummary ID="ValidationSummaryAddUser" runat="server" />
</td></tr>
<tr>
<td style="height: 24px"><asp:Button ID="ResetButton" runat="server" Text="Reset" /></td>
<td style="height: 24px"><asp:Button ID="SubmitButton" runat="server" Text="Submit" /></td>
<td style="height: 24px"></td>
</tr>
</table>


</div>
</asp:Content>

---

just how to make the SQLDataobject and submit button onclick to like each other?

Thanks again all.

Hi,

Based on your description, I understand that you have created a SqlDataSource control on a table, and have created Select, Insert and Update command on it. If there is any misunderstanding, please feel free to let me know.

Usually, the Select command is fired by calling DataBind method on the controls. When binding, the method is called and the returned DataReader or DataSet is automatically bind to the controls.

For Update and Insert method, you will have to call the Update() or Insert() manually. In your case, call SqlDataSource1.Update() in the Submit button. If it's a newly added record, call SqlDataSource1.Insert().

If you need to know if the record has been added, you can use IF EXISTS statement to check existence in database.

IF EXISTS (SELECT * FROM t1 WHERE id = @.id)
BEGIN
--Call Update
END
ELSE
BEGIN
--Call Insert
END

Hope this helps.


Thank you for your reply.

Since my post, I've been non-stop .NET-in-ating and I've learned much. I wound up doing the following

Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim intUserCount As Integer
Dim strSQL As String

strSQL = "Insert into Users " _
& "(FirstName, LastName, Username, Password, Permissionlevel)" _
& "VALUES ('" & Trim(Replace(TextboxFirstName.Text, "'", "''")) & "','" _
& Trim(Replace(TextboxLastName.Text, "'", "''")) & "','" _
& Trim(Replace(TextboxUsername.Text, "'", "''")) & "','" _
& Trim(Replace(TextboxPassword.Text, "'", "''")) & "','" _
& Trim(Replace(DropDownListPermissionLevel.SelectedItem.Value, "'", "''")) & "')"

myConnection = New OleDbConnection(System.Configuration.ConfigurationManager.AppSettings("strConn"))

myCommand = New OleDbCommand(strSQL, myConnection)

myConnection.Open()
intUserCount = myCommand.ExecuteScalar()
myConnection.Close()


End Sub

But now, I've learned how to modify the 'templates' for a gridview/detailsview combo. I'm an old ASP guy, as I've said. So, messing with this has been good exercise to understand what's going on.

Since this posting, I've changed my whole view of how a 'control panel' could/needs to be laid out. This new .NET stuff is changing my way of 'organizing control panel' type portions of web sites.

As an exercise I'm converting www.beaudamore.com/ProductionManagement form old ASP into ASP.NET using VB as the base code. The whole way the 'Menu' is laid out is going to change in respect to this whole new programming style. I'm envisioning it different, simpler, but equally powerful. I will post more, perhaps my view form old ASP will help other 'old timers' as well. I think I took too long to make the change.

Thanks again.

Submitting form with multiple onclick events

Hi

I'm building a custom control which basically takes data from the user
and then submits it. I would use the validator controls but if I
understand correctly (I've been working with .Net for 2 weeks) you
cant 'embed' them in the custom controls. Someone correct me if I'm
wrong (and please point to an example :) )

So, to get around this, I'm using Javascript. In my control, I'm doing

Writer.WriteAttribute("OnClick", "javascript:checkData();" &
Page.GetPostBackEventReference(Me, "Data"))

for an Input item so I get something like

<input type="button" value="Submit"
OnClick="javascript:checkData();__doPostBack('MyControl','D ata')" /
The checkData() function does this:

function checkLogin()
{
if (document.Data.item1.value == "" )
{
alert("Please enter item 1.");
return false;
}

if (document.Data.item2.value == "" )
{
alert("Please enter item 2.");
return false;
}

if (document.Data.item1.value != "" && document.Data.item2.value !=
"" )
{
return true;
}

}

My query is, how do I get the click event to fire correctly so that i
get alerts when there is a problem, and it passes through and submits
the form if there isnt a problem?

Thanks

SamHi,

Your client side script should use cancelBubble and returnValue to
disable event default process and raise alert if error found.

function CallServer()
{
if validate
{
__doPostBack('MyControl','Data');
}
else
{
alert("Error");
window.event.cancelBubble = true;
window.event.returnValue = false;
}
}

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Natty Gur <natty@.dao2com.com> wrote in message news:<uSSwHLhAEHA.3348@.TK2MSFTNGP11.phx.gbl>...
> Hi,
> Your client side script should use cancelBubble and returnValue to
> disable event default process and raise alert if error found.
> function CallServer()
> {
> if validate
> {
> __doPostBack('MyControl','Data');
> }
> else
> {
> alert("Error");
> window.event.cancelBubble = true;
> window.event.returnValue = false;
> }
> }
>
> HTH
> Natty Gur[MVP]
> blog : http://weblogs.asp.net/ngur
> Mobile: +972-(0)58-888377
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Thanks Natty

This means I have to create inline javascripts which I'd rather not do
if I can help it. Just as luck would have it, after spending an 'hour
or two' trying to find a solution before posting, 5 mins after posting
I find a solution :( Always the way...

Anyhow, just for reference purposes, what I've done is to validate on
OnMouseDown and postback on OnClick. Works a treat
Hi Samuel,

Its unfortunate that you had to rework validation because of some incorrect
information about validators. The ASP.NET validators work fine within custom
controls. They have one key limitation related to their "location": the
ControlToValidate must be associated with the ID of a control in the same
"naming container". If your custom control impliments INamingContainer,
ControlToValidate can only point to other controls within your custom
control. If not, it can refer to other controls in the same naming container
that your custom control appears. Some types of naming containers: Page,
UserControl, and rows in DataGrid and DataList.

If you wanted to support validation without naming container limits, I wrote
a replacement to Microsoft's validators that overcomes that limitation among
numerous others: Professional Validation And More.
http://www.peterblum.com/vam/home.aspx.

-- Peter Blum
www.PeterBlum.com
Email: PLBlum@.PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Samuel Hon" <noreply@.samuelhon.co.uk> wrote in message
news:c8672b7d.0403040703.c458604@.posting.google.co m...
> Hi
> I'm building a custom control which basically takes data from the user
> and then submits it. I would use the validator controls but if I
> understand correctly (I've been working with .Net for 2 weeks) you
> cant 'embed' them in the custom controls. Someone correct me if I'm
> wrong (and please point to an example :) )
> So, to get around this, I'm using Javascript. In my control, I'm doing
> Writer.WriteAttribute("OnClick", "javascript:checkData();" &
> Page.GetPostBackEventReference(Me, "Data"))
> for an Input item so I get something like
> <input type="button" value="Submit"
> OnClick="javascript:checkData();__doPostBack('MyControl','D ata')" />
> The checkData() function does this:
> function checkLogin()
> {
> if (document.Data.item1.value == "" )
> {
> alert("Please enter item 1.");
> return false;
> }
> if (document.Data.item2.value == "" )
> {
> alert("Please enter item 2.");
> return false;
> }
> if (document.Data.item1.value != "" && document.Data.item2.value !=
> "" )
> {
> return true;
> }
> }
> My query is, how do I get the click event to fire correctly so that i
> get alerts when there is a problem, and it passes through and submits
> the form if there isnt a problem?
> Thanks
> Sam
"Peter Blum" <PLBlum@.Blum.info> wrote in message news:<OC#ZP$uAEHA.624@.TK2MSFTNGP10.phx.gbl>...
> Hi Samuel,
> Its unfortunate that you had to rework validation because of some incorrect
> information about validators. The ASP.NET validators work fine within custom
> controls. They have one key limitation related to their "location": the
> ControlToValidate must be associated with the ID of a control in the same
> "naming container". If your custom control impliments INamingContainer,
> ControlToValidate can only point to other controls within your custom
> control. If not, it can refer to other controls in the same naming container
> that your custom control appears. Some types of naming containers: Page,
> UserControl, and rows in DataGrid and DataList.
> If you wanted to support validation without naming container limits, I wrote
> a replacement to Microsoft's validators that overcomes that limitation among
> numerous others: Professional Validation And More.
> http://www.peterblum.com/vam/home.aspx.
> -- Peter Blum
> www.PeterBlum.com
> Email: PLBlum@.PeterBlum.com
> Creator of "Professional Validation And More" at
> http://www.peterblum.com/vam/home.aspx
<snip
Thanks Peter for clearing that up, I will re-investigate

Sam

Thursday, March 22, 2012

Suppress Form Action

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):

<%@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

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

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):
<%@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?

Tuesday, March 13, 2012

SURVEY: How are you doing Global Error Handling in ASP.NET

Best I can tell, there are three basic ways you can deal with global
error handling in ASP.NET. Namely:

1. Derive all your pages from a custom Page class, and override
OnError()

2. Specify a custom 500 handler in Web.Config

3. Specify a custom 500 handler in IIS

and I guess you could add:

4. Let them fall through & spit out ugly error messages

I'm curious to see how people are doing it in the real world.
Personally, I've always used option #1, as it seems to offer the most
flexibility, and I'm already using custom Page objects, so it's no
extra work.

I'm asking this because we're getting close to a public BETA release
of Regressor.NET, and am considering adding support for cases 2 and
3. Before I commit the resources though, I'd like to get a feel for
how many people would benefit from it.

I look forward to seeing what people have to say. Thanks for the
help!

Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
ps. If anybody is interested in becoming a Beta tester for
Regressor.NET, let me know!Jason Kester schrieb:

Quote:

Originally Posted by

Best I can tell, there are three basic ways you can deal with global
error handling in ASP.NET. Namely:
>
1. Derive all your pages from a custom Page class, and override
OnError()
>
2. Specify a custom 500 handler in Web.Config
>
3. Specify a custom 500 handler in IIS
>
and I guess you could add:
>
4. Let them fall through & spit out ugly error messages


5. Use global.asax to catch errors

greets,
steve

--
Stefan Kalcher

Programming's just like sex, one mistake, you support it for life.
On Mar 12, 1:29 am, "Jason Kester" <jasonkes...@dotnet.itags.org.gmail.comwrote:

Quote:

Originally Posted by

Best I can tell, there are three basic ways you can deal with global
error handling in ASP.NET. Namely:
>
1. Derive all your pages from a custom Page class, and override
OnError()
>
2. Specify a custom 500 handler in Web.Config
>
3. Specify a custom 500 handler in IIS
>
and I guess you could add:
>
4. Let them fall through & spit out ugly error messages
>
I'm curious to see how people are doing it in the real world.
Personally, I've always used option #1, as it seems to offer the most
flexibility, and I'm already using custom Page objects, so it's no
extra work.
>
I'm asking this because we're getting close to a public BETA release
of Regressor.NET, and am considering adding support for cases 2 and
3. Before I commit the resources though, I'd like to get a feel for
how many people would benefit from it.
>
I look forward to seeing what people have to say. Thanks for the
help!
>
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.regressor.net/
>
ps. If anybody is interested in becoming a Beta tester for
Regressor.NET, let me know!


In my application, I do the following:

1.) All of my Web forms derive from a base Page class. OnError is
overridden to handle errors there.

2.) I also handle exceptions in Global.asax, in the event that I've
missed something.

3.) Wherever the default handlers in my base class and/or Global.asax
aren't appropriate, I implement suitable exception handling.

4.) The application has a custom web page, which is itself an aspx
page. Some might have a tough time with that design, but it's
*extremely* stable, and doesn't do anything subject to failure.

5.) Every exception is logged to the database (if possible) and to the
Windows event log.

Yeah. I take 'em very seriously.
I'm also a big fan of the custom Page idea. And I agree that logging
everything is important (that's why we wrote Regressor.NET!) It's
amazing how much you find out about your application when every single
exception gets logged.

Curious though, how many exceptions are you really seeing fall through
to Global.asax? I've seen a few posts on this thread from people that
are using Global.asax as a backup, but personally I've never had a
problem with the overriden OnError in my custom page classes. At
least I've never seen anything fall through in person, but then I
guess I'd never know if anything were slipping through the cracks...

Mike, do you forward crash reports directly to your bug tracking
software?

Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@dotnet.itags.org.gmail.comwrote:

Quote:

Originally Posted by

In my application, I do the following:
>
1.) All of my Web forms derive from a base Page class. OnError is
overridden to handle errors there.
>
2.) I also handle exceptions in Global.asax, in the event that I've
missed something.
>
3.) Wherever the default handlers in my base class and/or Global.asax
aren't appropriate, I implement suitable exception handling.
>
4.) The application has a custom web page, which is itself an aspx
page. Some might have a tough time with that design, but it's
*extremely* stable, and doesn't do anything subject to failure.
>
5.) Every exception is logged to the database (if possible) and to the
Windows event log.
>
Yeah. I take 'em very seriously.- Hide quoted text -
>
- Show quoted text -


On Mar 12, 3:04 pm, "Jason Kester" <jasonkes...@dotnet.itags.org.gmail.comwrote:

Quote:

Originally Posted by

I'm also a big fan of the custom Page idea. And I agree that logging
everything is important (that's why we wrote Regressor.NET!) It's
amazing how much you find out about your application when every single
exception gets logged.
>
Curious though, how many exceptions are you really seeing fall through
to Global.asax? I've seen a few posts on this thread from people that
are using Global.asax as a backup, but personally I've never had a
problem with the overriden OnError in my custom page classes. At
least I've never seen anything fall through in person, but then I
guess I'd never know if anything were slipping through the cracks...
>
Mike, do you forward crash reports directly to your bug tracking
software?
>
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.regressor.net/
>
On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@dotnet.itags.org.gmail.comwrote:
>
>
>

Quote:

Originally Posted by

In my application, I do the following:


>

Quote:

Originally Posted by

1.) All of my Web forms derive from a base Page class. OnError is
overridden to handle errors there.


>

Quote:

Originally Posted by

2.) I also handle exceptions in Global.asax, in the event that I've
missed something.


>

Quote:

Originally Posted by

3.) Wherever the default handlers in my base class and/or Global.asax
aren't appropriate, I implement suitable exception handling.


>

Quote:

Originally Posted by

4.) The application has a custom web page, which is itself an aspx
page. Some might have a tough time with that design, but it's
*extremely* stable, and doesn't do anything subject to failure.


>

Quote:

Originally Posted by

5.) Every exception is logged to the database (if possible) and to the
Windows event log.


>

Quote:

Originally Posted by

Yeah. I take 'em very seriously.- Hide quoted text -


>

Quote:

Originally Posted by

- Show quoted text -- Hide quoted text -


>
- Show quoted text -


Unfortunately, no, but that's due to the disconnected nature of our
system. The bug tracking database is housed here, at the software
shop, and the software itself is located on the production server at
the client -- in a different state, on a secure system, behind a
firewall, and to which we have no access. We are not permitted any
access to that system, due to security concerns. (It's a government
agency.)

The database contains an error log table; we are fortunate enough to
be able to receive backups of the database for data mining purposes,
and we mine that table to monitor exceptions for stuff that we missed.
I'm pleased to report that our unhandled exception rate is *extremely*
low.

We use BugTracker.NET here to track defects. It's rudimentary, but it
gets the job done for what we need. If we were able to write a secure
Web service to shuffle the data across the wire to BugTracker, I would
definitely be interested in doing that, but I don't think the client
will approve that any time in the near future. (Money is always a big
concern, and they have other things they want to get done at this
point in time. Since we are doing things pretty well "status quo,"
they're likely going to take the point of view that we can survive as
we are until it becomes a truly pressing concern. And if it ever came
to that, it would speak volumes about my code quality--they'd likely
need to hire a new developer, and I'd be brushing off my resume.)
On Mar 12, 3:04 pm, "Jason Kester" <jasonkes...@dotnet.itags.org.gmail.comwrote:

Quote:

Originally Posted by

I'm also a big fan of the custom Page idea. And I agree that logging
everything is important (that's why we wrote Regressor.NET!) It's
amazing how much you find out about your application when every single
exception gets logged.
>
Curious though, how many exceptions are you really seeing fall through
to Global.asax? I've seen a few posts on this thread from people that
are using Global.asax as a backup, but personally I've never had a
problem with the overriden OnError in my custom page classes. At
least I've never seen anything fall through in person, but then I
guess I'd never know if anything were slipping through the cracks...
>
Mike, do you forward crash reports directly to your bug tracking
software?
>
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.regressor.net/
>
On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@dotnet.itags.org.gmail.comwrote:
>
>
>

Quote:

Originally Posted by

In my application, I do the following:


>

Quote:

Originally Posted by

1.) All of my Web forms derive from a base Page class. OnError is
overridden to handle errors there.


>

Quote:

Originally Posted by

2.) I also handle exceptions in Global.asax, in the event that I've
missed something.


>

Quote:

Originally Posted by

3.) Wherever the default handlers in my base class and/or Global.asax
aren't appropriate, I implement suitable exception handling.


>

Quote:

Originally Posted by

4.) The application has a custom web page, which is itself an aspx
page. Some might have a tough time with that design, but it's
*extremely* stable, and doesn't do anything subject to failure.


>

Quote:

Originally Posted by

5.) Every exception is logged to the database (if possible) and to the
Windows event log.


>

Quote:

Originally Posted by

Yeah. I take 'em very seriously.- Hide quoted text -


>

Quote:

Originally Posted by

- Show quoted text -- Hide quoted text -


>
- Show quoted text -


In regards to your questions regarding exceptions that fall through to
global.asax, I've only seen this a handful of times at best. But when
they did, I was *very* thankful it was there. Since we log everything
to our database, data mining helps us to uncover those unhandled
exceptions and treat them as critical defects that require immediate
resolution.
Yeah, it's tough having to work in the real world. Best practices
have a way of slipping through the cracks at most places.

Here at Expat Software we use Fogbugz, so we have the option of
sending out crash report distress calls either by Email or via HTTP.
Either way, Fogbugz will automatically log a new case for us.

Regardless, it sounds like you're well ahead of the game. I suspect
that most shops have never considered logging exceptions at all!

Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 12:14 pm, "Mike Hofer" <kchighl...@dotnet.itags.org.gmail.comwrote:

Quote:

Originally Posted by

>
Unfortunately, no, but that's due to the disconnected nature of our
system. The bug tracking database is housed here, at the software
shop, and the software itself is located on the production server at
the client -- in a different state, on a secure system, behind a
firewall, and to which we have no access. We are not permitted any
access to that system, due to security concerns. (It's a government
agency.)
>


Yeah, it's tough having to work in the real world. Best practices
have a way of slipping through the cracks at most places.

Here at Expat Software we use Fogbugz, so we have the option of
sending out crash report distress calls either by Email or via HTTP.
Either way, Fogbugz will automatically log a new case for us.

Regardless, it sounds like you're well ahead of the game. I suspect
that most shops have never considered logging exceptions at all!

Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 12:14 pm, "Mike Hofer" <kchighl...@dotnet.itags.org.gmail.comwrote:

Quote:

Originally Posted by

>
Unfortunately, no, but that's due to the disconnected nature of our
system. The bug tracking database is housed here, at the software
shop, and the software itself is located on the production server at
the client -- in a different state, on a secure system, behind a
firewall, and to which we have no access. We are not permitted any
access to that system, due to security concerns. (It's a government
agency.)
>

SURVEY: How are you doing Global Error Handling in ASP.NET

Best I can tell, there are three basic ways you can deal with global
error handling in ASP.NET. Namely:
1. Derive all your pages from a custom Page class, and override
OnError()
2. Specify a custom 500 handler in Web.Config
3. Specify a custom 500 handler in IIS
and I guess you could add:
4. Let them fall through & spit out ugly error messages
I'm curious to see how people are doing it in the real world.
Personally, I've always used option #1, as it seems to offer the most
flexibility, and I'm already using custom Page objects, so it's no
extra work.
I'm asking this because we're getting close to a public BETA release
of Regressor.NET, and am considering adding support for cases 2 and
3. Before I commit the resources though, I'd like to get a feel for
how many people would benefit from it.
I look forward to seeing what people have to say. Thanks for the
help!
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
ps. If anybody is interested in becoming a Beta tester for
Regressor.NET, let me know!Jason Kester schrieb:
> Best I can tell, there are three basic ways you can deal with global
> error handling in ASP.NET. Namely:
> 1. Derive all your pages from a custom Page class, and override
> OnError()
> 2. Specify a custom 500 handler in Web.Config
> 3. Specify a custom 500 handler in IIS
> and I guess you could add:
> 4. Let them fall through & spit out ugly error messages
5. Use global.asax to catch errors
greets,
steve
Stefan Kalcher
Programming's just like sex, one mistake, you support it for life.
On Mar 12, 1:29 am, "Jason Kester" <jasonkes...@.gmail.com> wrote:
> Best I can tell, there are three basic ways you can deal with global
> error handling in ASP.NET. Namely:
> 1. Derive all your pages from a custom Page class, and override
> OnError()
> 2. Specify a custom 500 handler in Web.Config
> 3. Specify a custom 500 handler in IIS
> and I guess you could add:
> 4. Let them fall through & spit out ugly error messages
> I'm curious to see how people are doing it in the real world.
> Personally, I've always used option #1, as it seems to offer the most
> flexibility, and I'm already using custom Page objects, so it's no
> extra work.
> I'm asking this because we're getting close to a public BETA release
> of Regressor.NET, and am considering adding support for cases 2 and
> 3. Before I commit the resources though, I'd like to get a feel for
> how many people would benefit from it.
> I look forward to seeing what people have to say. Thanks for the
> help!
> Jason Kester
> Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.reg
ressor.net/
> ps. If anybody is interested in becoming a Beta tester for
> Regressor.NET, let me know!
In my application, I do the following:
1.) All of my Web forms derive from a base Page class. OnError is
overridden to handle errors there.
2.) I also handle exceptions in Global.asax, in the event that I've
missed something.
3.) Wherever the default handlers in my base class and/or Global.asax
aren't appropriate, I implement suitable exception handling.
4.) The application has a custom web page, which is itself an aspx
page. Some might have a tough time with that design, but it's
*extremely* stable, and doesn't do anything subject to failure.
5.) Every exception is logged to the database (if possible) and to the
Windows event log.
Yeah. I take 'em very seriously.
I'm also a big fan of the custom Page idea. And I agree that logging
everything is important (that's why we wrote Regressor.NET!) It's
amazing how much you find out about your application when every single
exception gets logged.
Curious though, how many exceptions are you really seeing fall through
to Global.asax? I've seen a few posts on this thread from people that
are using Global.asax as a backup, but personally I've never had a
problem with the overriden OnError in my custom page classes. At
least I've never seen anything fall through in person, but then I
guess I'd never know if anything were slipping through the cracks...
Mike, do you forward crash reports directly to your bug tracking
software?
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@.gmail.com> wrote:
> In my application, I do the following:
> 1.) All of my Web forms derive from a base Page class. OnError is
> overridden to handle errors there.
> 2.) I also handle exceptions in Global.asax, in the event that I've
> missed something.
> 3.) Wherever the default handlers in my base class and/or Global.asax
> aren't appropriate, I implement suitable exception handling.
> 4.) The application has a custom web page, which is itself an aspx
> page. Some might have a tough time with that design, but it's
> *extremely* stable, and doesn't do anything subject to failure.
> 5.) Every exception is logged to the database (if possible) and to the
> Windows event log.
> Yeah. I take 'em very seriously.- Hide quoted text -
> - Show quoted text -
On Mar 12, 3:04 pm, "Jason Kester" <jasonkes...@.gmail.com> wrote:
> I'm also a big fan of the custom Page idea. And I agree that logging
> everything is important (that's why we wrote Regressor.NET!) It's
> amazing how much you find out about your application when every single
> exception gets logged.
> Curious though, how many exceptions are you really seeing fall through
> to Global.asax? I've seen a few posts on this thread from people that
> are using Global.asax as a backup, but personally I've never had a
> problem with the overriden OnError in my custom page classes. At
> least I've never seen anything fall through in person, but then I
> guess I'd never know if anything were slipping through the cracks...
> Mike, do you forward crash reports directly to your bug tracking
> software?
> Jason Kester
> Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.reg
ressor.net/
> On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@.gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> - Show quoted text -
Unfortunately, no, but that's due to the disconnected nature of our
system. The bug tracking database is housed here, at the software
shop, and the software itself is located on the production server at
the client -- in a different state, on a secure system, behind a
firewall, and to which we have no access. We are not permitted any
access to that system, due to security concerns. (It's a government
agency.)
The database contains an error log table; we are fortunate enough to
be able to receive backups of the database for data mining purposes,
and we mine that table to monitor exceptions for stuff that we missed.
I'm pleased to report that our unhandled exception rate is *extremely*
low.
We use BugTracker.NET here to track defects. It's rudimentary, but it
gets the job done for what we need. If we were able to write a secure
Web service to shuffle the data across the wire to BugTracker, I would
definitely be interested in doing that, but I don't think the client
will approve that any time in the near future. (Money is always a big
concern, and they have other things they want to get done at this
point in time. Since we are doing things pretty well "status quo,"
they're likely going to take the point of view that we can survive as
we are until it becomes a truly pressing concern. And if it ever came
to that, it would speak volumes about my code quality--they'd likely
need to hire a new developer, and I'd be brushing off my resume.)
On Mar 12, 3:04 pm, "Jason Kester" <jasonkes...@.gmail.com> wrote:
> I'm also a big fan of the custom Page idea. And I agree that logging
> everything is important (that's why we wrote Regressor.NET!) It's
> amazing how much you find out about your application when every single
> exception gets logged.
> Curious though, how many exceptions are you really seeing fall through
> to Global.asax? I've seen a few posts on this thread from people that
> are using Global.asax as a backup, but personally I've never had a
> problem with the overriden OnError in my custom page classes. At
> least I've never seen anything fall through in person, but then I
> guess I'd never know if anything were slipping through the cracks...
> Mike, do you forward crash reports directly to your bug tracking
> software?
> Jason Kester
> Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.reg
ressor.net/
> On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@.gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> - Show quoted text -
In regards to your questions regarding exceptions that fall through to
global.asax, I've only seen this a handful of times at best. But when
they did, I was *very* thankful it was there. Since we log everything
to our database, data mining helps us to uncover those unhandled
exceptions and treat them as critical defects that require immediate
resolution.
Yeah, it's tough having to work in the real world. Best practices
have a way of slipping through the cracks at most places.
Here at Expat Software we use Fogbugz, so we have the option of
sending out crash report distress calls either by Email or via HTTP.
Either way, Fogbugz will automatically log a new case for us.
Regardless, it sounds like you're well ahead of the game. I suspect
that most shops have never considered logging exceptions at all!
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 12:14 pm, "Mike Hofer" <kchighl...@.gmail.com> wrote:
> Unfortunately, no, but that's due to the disconnected nature of our
> system. The bug tracking database is housed here, at the software
> shop, and the software itself is located on the production server at
> the client -- in a different state, on a secure system, behind a
> firewall, and to which we have no access. We are not permitted any
> access to that system, due to security concerns. (It's a government
> agency.)
>
Yeah, it's tough having to work in the real world. Best practices
have a way of slipping through the cracks at most places.
Here at Expat Software we use Fogbugz, so we have the option of
sending out crash report distress calls either by Email or via HTTP.
Either way, Fogbugz will automatically log a new case for us.
Regardless, it sounds like you're well ahead of the game. I suspect
that most shops have never considered logging exceptions at all!
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 12:14 pm, "Mike Hofer" <kchighl...@.gmail.com> wrote:
> Unfortunately, no, but that's due to the disconnected nature of our
> system. The bug tracking database is housed here, at the software
> shop, and the software itself is located on the production server at
> the client -- in a different state, on a secure system, behind a
> firewall, and to which we have no access. We are not permitted any
> access to that system, due to security concerns. (It's a government
> agency.)
>