Jump to content
Xtreme .Net Talk

HardCode

Avatar/Signature
  • Posts

    49
  • Joined

  • Last visited

Everything posted by HardCode

  1. I have a Web Content Page in an ASP.NET 2005 Web Application project (the one that compiles all code-behind to one .DLL), using MS AJAX and VB.NET code-behind. I have several pages that allow users to maintain system tables (e.g. States, Countries, Departments, etc.) For some odd reason, when I click on the Add or Update ASP.NET Button controls, the PostBack doesn't always fire for the page. I proved this by running the web app in debug mode with breakpoints on the event handlers. It will fire if I re-click the button a second time. It always will work the second time at worst, and will never "not fire" more than once. The page directive AutoEventWireup is set to false. I've use both the Handles btnUpdate.Click method of wiring up the even, as well as changing it to the markup declaration OnClick="btnUpdate_Click". Both of these methods will produce the the same behavior described above. This behavior also happens on all of these maintenance pages. When I stated that the button doesn't always fire, it's because it may work if I don't click the GridView control on the page (the list of existing entities) when doing an Add. It sometimes will not fire when I do click on an existing entity in the GridView, change the value in a TextBox, and click Update. This behavior doesn't happen on any other pages in my web app. The only commonality in these maintenance pages is that the pages are basically copies of each other for the most part, with the exception of the controls housing the details of the selected entity item (e.g. one text box on the Department Maintenance page for the Dept. name, but two TextBoxes on the State Maintenance page for the State Code and State name). I've googled around and haven't found anything similar to my issue. Any help would be appreciated. An example .aspx page: <%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Master/AppMaster.Master" CodeBehind="DeptMaint.aspx.vb" Inherits="<project name omitted for this thread>.DeptMaint" title="Department Maintenance" %> <!-- more controls ommitted for forum posting --> <asp:GridView ID="gvExisting" runat="server" AutoGenerateSelectButton="True" CellPadding="2" CellSpacing="1" CssClass="gridViewMain" GridLines="None" AllowPaging="true" Width="500px" PageSize="15"> <EmptyDataRowStyle CssClass="gridViewRow" /> <RowStyle CssClass="gridViewRow" /> <SelectedRowStyle CssClass="gridViewSelectedRow" /> <HeaderStyle CssClass="gridViewHeader" /> <AlternatingRowStyle CssClass="gridViewAlternatingRow" /> </asp:GridView> <br /> <asp:Label ID="lblName" runat="server" Text="Department Name:"> </asp:Label> <asp:TextBox ID="txtName" runat="server" Width="300px" AutoPostBack="True"> </asp:TextBox> <br /><br /> <asp:Button ID="btnAdd" runat="server" Text="Add" Width="64px" OnClick="btnAdd_Click" /> <asp:Button ID="btnUpdate" runat="server" Text="Update" Width="64px" OnClick="btnUpdate_Click" /> <asp:Button ID="btnDelete" runat="server" Text="Delete" Width="64px" OnClick="btnDelete_Click" /> And the code-behind (pretty standard) with the Handles method commented out: Protected Sub btnAdd_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) 'Handles btnAdd.Click Try Me.Add() Catch ex As Exception Throw End Try End Sub Protected Sub btnDelete_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) 'Handles btnDelete.Click Try Me.Delete() Catch ex As Exception Throw End Try End Sub Protected Sub btnUpdate_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) 'Handles btnUpdate.Click Try Me.Update() Catch ex As Exception Throw End Try End Sub Protected Sub gvExisting_PageIndexChanging(ByVal sender As Object, _ ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvExisting.PageIndexChanging Try MySession.PageIndex = e.NewPageIndex Me.InitList() Catch ex As Exception Throw End Try End Sub Protected Sub gvDepartments_SelectedIndexChanged(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles gvExisting.SelectedIndexChanged Try If Me.gvExisting.SelectedRow IsNot Nothing Then Me.txtName.Text = Server.HtmlDecode(Me.gvExisting.SelectedRow.Cells(2).Text).Trim End If Catch ex As Exception Throw End Try End Sub
  2. I've created a user control (.ascx). This user control contains an HTML table with one table row, three table details. The first TD contains an ASP Label control. The second contains a RadioButtonList with two options ("New", "Existing"). The third contains a DropDownList. In the .ascx control, the Label's text is set using a Public Property of type String, and the DropDownList's data source is set by a Public Property of type SqlClient.SqlDataReader. The reader will return about 6100 customers. The radio buttons are static. I am using this control on an .aspx page with a GridView and an empty Panel control. When I click on "select" in the GridView, I create my user control and add it to the Panel control. So far, I only add one user control. I will need to add more after I figure out the answer to my problem. The first time I click "select" in the GridView, the user control takes about two seconds to show up on the page. That's fine. However, if I click another item in the GridView, the browser locks up for about a minute. Stepping through the code, I can reach the "End Sub" of the event "myGridView_SelectedIndexChanged(). However, stepping past this End Sub locks up the browser. There is no other VB code running after that End Sub or after the lock up. I really have no idea what is going on here. I should note that I am using AJAX, so all of the above-mentioned controls are in an AJAX UpdatePanel. One other note, IE locks up for about a minute, but Firefox locks up for about 5 seconds (which is still longer than clicking the GridView the first time). Another caveat ... this control is going to be used to determine if a customer in the GridView (coming from an ERP system) is already in "our" SQL Server database, so all of "our" customers have to be in one DropDownList. The SqlDataReader assigned to the DropDownList comes from "our" database. I don't want to post a whole slew of code, so I'll just start with the GridView event and the user control creation: Private Sub gvNewCustomers_SelectedIndexChanged(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles gvNewCustomers.SelectedIndexChanged Try Dim sCustID As String Dim sCustName As String sCustID = Me.gvNewCustomers.SelectedRow.Cells(2).Text sCustName = Me.gvNewCustomers.SelectedRow.Cells(3).Text Call AddDynamicControls(sCustID, sCustName) Catch ex As Exception Throw End Try End Sub ' ***** Freezes here (the last line of code before the page renders) Private Sub AddDynamicControls(ByVal custId As String, ByVal custName As String) Try ' Clear out the Placeholder of any existing controls. Me.pnlDynamicControls.Controls.Clear() ' Add the customer control Call AddCustomerDynamicControls(custId, custName) ' Add an HTML Horizontal row Me.pnlDynamicControls.Controls.Add(New HtmlGenericControl("hr")) ' TODO: Add the address controls Catch ex As Exception Throw End Sub Private Sub AddCustomerDynamicControls(ByVal custId As String, ByVal custName As String) Try Dim oEntity As Control = LoadControl("EntitySelector.ascx") CType(oEntity, EntitySelector).ID = "entity_Cust_" & custId CType(oEntity, EntitySelector).LabelText = custName CType(oEntity, EntitySelector).DropDownDataSource = CreateCustomerDataReader() Me.pnlDynamicControls.Controls.Add(oEntity) Catch ex As Exception Throw End Try End Sub
  3. Re: Unnecessary string conversion Excellent explanations. It has helped me, also.
  4. I have a very similar question, so to avoid a duplicate thread, perhaps I can join in on this discussion of Shared, and davearia and I can both benefit from a response. I was wondering how a Public Shared function in a "helper" class, which validates a string for Not String.IsNullOrEmpty and also validated length, would be affected by multiple users calling this function at the same time. The answer will probably be the same for davearia's "calculates VAT" question above? EDIT: MrPaul got in an answer before I finished the post, so I assume that I'd not have a problem with Shared itself for my example?
  5. I have created a few styles in a style sheet for required form fields. Just the basic font-family, color: red kind of stuff. The styles show up in the IDE in design mode when looking at the page. However, if I run the web site in the IDE, the styles do not apply to the controls! If I open this (local IIS) web page with Firefox, the styles are applied. Only seems IE doesn't want to do what VS.NET 2005 recognizes ... Anyone have any ideas? I can provide code if this is a new one for the community.
  6. I am using the following Private Sub of a class to send e-mail. My company uses Norton to scan outgoing e-mails. This function, in VB.NET 2003, used System.Web.Mail, from a Windows Application, and sent the e-mails immediately. Now, using it in VB.NET 2005 and System.Net.Mail, the e-mails do not get sent until I close the program to which this class belongs (being run in both Debug configuration via the IDE and the compiled .EXE). It's very strange. I have no idea how or why the e-mails would be caching somewhere until the program is closed. I know this is happening, because after I close the program, Norton lights up the System Tray like fireworks, for each e-mail being sent. Private Sub SendInvite(ByVal Subject As String, ByVal Body As String, ByVal SendTo As String, _ ByVal Link As String, ByVal Incentive As Integer, ByVal TimeText As String) Try Dim mailMessage As System.Net.Mail.MailMessage Dim mailFrom As System.Net.Mail.MailAddress Dim mailTo As System.Net.Mail.MailAddress Dim mailSMTP As System.Net.Mail.SmtpClient Subject = Replace(Subject, "<SNIP>", TimeText) Body = Replace(Body, "<Link>", Space(5) & Link) Body = Replace(Body, "<Incentive>", Incentive.ToString) Body = Replace(Body, "<TimeText>", TimeText) mailFrom = New System.Net.Mail.MailAddress("<SNIP>", "<SNIP>") mailTo = New System.Net.Mail.MailAddress(SendTo) mailMessage = New System.Net.Mail.MailMessage(mailFrom, mailTo) mailMessage.Subject = Subject mailMessage.BodyEncoding = System.Text.Encoding.UTF8 mailMessage.Body = Body mailSMTP = New System.Net.Mail.SmtpClient(sSmtpServer) mailSMTP.Send(mailMessage) Catch ex As Exception Throw (ex) End Try End Sub Variable sSmtpServer is a Private class-level variable assigned by a Public Property of the class.
  7. I have a Panel docked to the bottom of a form, with the some buttons on the right hand side of the Panel. On Form_Resize, I programmatically set the position of the buttons so that its position on the right is consistent, regardless of the form size. btnClose.Left = pnlButtons.Width - btnClose.Width - 10 btnRefresh.Left = pnlButtons.Width - btnRefresh.Width - btnClose.Width - 20 btnUpdate.Left = pnlButtons.Width - btnUpdate.Width - btnRefresh.Width - btnClose.Width - 30 Now, in the Form_Load event I set the form to FormWindowState.Maximized, and the Form_Resize event is raised. However, at this time, the form is still the size as it is in the designer. Even explicitly calling Form_Resize again after setting it Maximized leaves me with the dimensions of the form in the designer (the form hasn't actually maximized until the Load event has completed). Because of this, the buttons are in the wrong place on the form. They are not repositioned after the form loads. I can't seem to find an event that fires automatically after Form_Load, and after the form is actually maximized and the new size is accessible. Or, is there a way in the designer to tell the controls to "stay where they are" in relation to the Panel, regardless of the Form and Panel resizing?
  8. Thanks. That fixed it!
  9. I created some new folders in the Project Explorer to organize different forms. In doing so, one form became disassocaited from its .designer.vb and .resx files. Below is a screenshot. How can I reassociate them? None of the form's objects are rendering in the IDE now? This is a Windows Application using SourceSafe 6.0x source control.
  10. No, nothing at all. Just a default .NET controls on default forms assigned as Child Forms. Most odd ...
  11. No ... I even tried again. CTRL+C won't copy the selected text to the Clipboard. Some things about this form that may be preventing this: 1. The form is an ChildForm of an MDI Form 2. The TextBox control is within a Split control. 3. The TextBox control is set to Multiline. 4. No KeyPreview properties were changed. 5. The ChildForms are being set up as a single-instance only, via creating public properties on the MDI Parent, of type frm<MyForm>: Public Property NewQuestionForm() As frmNewQuestion Get If (fNewQuestion Is Nothing) OrElse (fNewQuestion.IsDisposed) Then fNewQuestion = New frmNewQuestion fNewQuestion.MdiParent = Me End If Return fNewQuestion End Get Set(ByVal Value As frmNewQuestion) fNewQuestion = Value End Set End Property Let me start a new project and try it with the default form to see if it is only this project or not. EDIT: Okay, so I started a new project and tried it. The keyboard shortcuts work fine. I tried with both the default TextBox, and I tried it with Multiline as true. Works fine. Hmmm, something about my specific project I think. I tried it on another MDI form in the problem project, and no keyboard copy-n-paste functionality either.
  12. I can right-click in a TextBox control for the default ContextMenu with Cut, Copy, and Paste. However, I've noticed that in VB.NET 2005, you can't select text in a TextBox control and press CTRL+C, CTRL+X, or CTRL+V in them to cut, copy, or paste. I don't recall this behavior with VB.NET 2003, and definitely not with VB6 or Access VBA. Those TextBox controls always recognize the keyboard commands. Is it that Microsoft's TextBox control doesn't realize these keypresses by default anymore? I tried setting the form's KeyPreview property to true to no avail. It seems kind of strange that you can no longer use the keyboard shortcuts for such basic functionality. Or, am I just missing something here?
  13. Thanks for the tip on determining DesignMode. Interestingly, this behavior seems to be a bug with the Panel control. Let me explain ... I added a Panel at the bottom of my form to contain the Close UC that was already on the form. So, I dragged the Close control into the Panel, and voila! the behavior started. By deleting the control and re-adding it from the tool box directly onto the Panel, the behavior went away. Strange! Someone at XTreme VB Talk replicated this odd behavior on their system too (this is VS.NET 2003) and commented that nested controls in VB6 worked the same way. She was surprised the behavior "carried over" into .NET. However, seems with that code snippet you provided I can be sure that it won't happen again! Thanks.
  14. I created a simple user control for Windows Forms for some learning experience, but I will use it in a production program. The control is basically a Button control dragged into the UserControl draw area, with one event: Public Class ucCloseButton Inherits System.Windows.Forms.UserControl #Region " Windows Form Designer generated code " #Region "Events" Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles btnClose.Click Me.ParentForm.Close() End Sub #End Region End Class I can drop this UC on my other forms, and the button will close the form that it is on. I figured I can avoid having to code the btnClose event in every form that I create by just using this control. However! The button actually closes the form in DESIGN time as well as runtime. If I am designing the form and I click the control, the form disappears from the design window! Ack! Is there a way that I can tell my control to only be active during run-time to fix this bug I have created? Do UCs have a different conception of run-time?
  15. Didn't get it from you ... got it from a free avatar web site.
  16. I searched "All Products" at Microsoft to check the cost of licensing the tool before I spend time trying it out, but it doesn't come up in either the search or by browsing all products in alphabetical order. Does anyone know how much it costs?
  17. Do you mean make the users' domain accounts also local user accounts on the server machine?
  18. Go to http://www.asp.net. It is a Microsoft website. Download the free ASP.NET IDE called Web Matrix. Create a new .ASPX page, and it will give you a section at the top <script runat="server"> </script>. Drop and drag a textbox on the web form. Back in the code, put in that script section: Sub Page_Load() TextBox1.Text = Response.QueryString("name") End Sub That should get you started! You can also run, within Web Matrix, the ASPX pages because it initiates a virtual web server for you :) .
  19. Using Windows Authentication in VB with ADO to SQL Server means that as long as the user is logged in to the PC on the domain, they can access the SQL Server without supplying another login name and password. While a different platform, I am trying to use Windows Authentication for the IIS App. My web.config is all set properly. On my local PC install of IIS, I can access the application in IE without having to supply a user name and password. However, when I move the app to the IIS Server on our LAN, I get the pop-up login box when trying to access the app. I can log in and access the app, but this defeats the intent of using Windows Auth doesn't it? Why would I not get the login popup on my local PC but I do get it on the server on the LAN?
  20. No, I just opened a stand-alone .ASPX page (that I had created in a text editor) with VS.NET 2003, and there is no "design mode." For a Web Application solution I created, the .ASPX pages have a design mode (see image.) The design mode only seems available when an .ASPX page is within the context of a .SLN. The first image is when main.aspx is opened as a part of a .sln project. The second image is when I open only main.aspx alone in VS.NET.
  21. If I create a Web Application, I have Design and HTML buttons at the bottom of the .ASPX page. This allows me to drag-n-drop controls onto the page like a Windows Form. However, if I open only a single .ASPX page in VS.NET, then the Design mode is not available. Is there a way to make it available? I checked all the View ---> windows but I don't see anything for this.
  22. There is a lot of technical talk in MSDN about authentication methods. I just want to make sure I understand Windows mode. If I set the application to Digest and Windows authentication (in IIS management console, right-click the application, select Properties, Directory security tab, Edit button, and uncheck anonymous access and Basic authentication, leaving only Digest and Integrated Windows), then is this true: The application and its pages, that is part of a web site open to the public, will ONLY be accessible to people on my company's Windows domain? Outsiders will not be able to access this application at all? Would it be more security-conscious to instead create a new Web Site on this server and host my intercompany Web Application under that? It may be wise to mention that while this server is part of the internal WAN (I access it by internal IP), it is not a part of the Domain that we log in to. It is in a "red zone" between the external firewall and then an internal firewall. When I remote-desktop to the machine, I log in with a separate local machine account. Will this affect Windows authentication? Microsoft isn't know for plain English :(
  23. Yes, I found the QuickStart Guide at Microsoft's GoDotNet ( http://samples.gotdotnet.com/quickstart/aspplus/ ) while Google'ing for Forms Authentication. Thanks Damp!
  24. Suppose I create a new Web Application in VS.NET 2003. I want the first page to be a login page. All pages in the app require the users to be logged in. Say one page is http://www.mysite.bla/payroll.aspx. Supposed someone types this page in the address bar, without ever logging in. What is the standard way of checking if a user is properly logged in so that they cannot just get creative and type pages in the address bar to bypass the login.
  25. I am not doing it through VS.NET using a Web Application. I am just creating the files in Web Matrix and putting them into the wwwroot directory. Would this make a difference since nothing is "binding" the files together except for their presence in the same directory (../wwwroot/mypages/Conn.vb)?
×
×
  • Create New...