Jump to content
Xtreme .Net Talk

mike55

Avatar/Signature
  • Posts

    734
  • Joined

  • Last visited

Everything posted by mike55

  1. I have a button for removing members from a grid, as a safety measure, I want to display a javascript dialog box that requires the user to confirm the action. I am using the following code: btnRemove.Attributes.Add("onclick", "return ConfirmAction('Remove selected Members?');") I have used this code previously without any hassle or errors, I am now getting the following, and the message dialog will not display: Any suggestions? Mike55.
  2. Can anyone spot the problem with this code: clsConnection.OpenConnection(cnConn) quickAddAdapter.SelectCommand = New SqlCommand quickAddAdapter.SelectCommand.Connection = cnConn quickAddAdapter.SelectCommand.CommandText = "QuickSelectMembers" quickAddAdapter.SelectCommand.CommandType = CommandType.StoredProcedure quickAddAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Organisation", SqlDbType.NVarChar, 10)) quickAddAdapter.SelectCommand.Parameters("@Organisation").Direction = ParameterDirection.Input quickAddAdapter.SelectCommand.Parameters("@Organisation").Value = organisation quickAddAdapter.Fill(dsReturn, "Everybody") The procedure works correctly, I have manually ran it and it returns all the expected data. The error message that I am getting is: Mike55.
  3. Hi Can anyone recommend a good OO Design book based on .net, in particular one that focuses on web development. My reasoning behind seeking such a books is that I really, really want to improve the quality of the software that I write. I am preparing to begin using TDD as one approach to improving the quality, but I believe that if I can improve the design of my programs, this will have the desired effect. Alternatively, I would be delighted to hear of any other book titles that could help with improving the quality of my software. Mike55.
  4. Hi all Which is more effective/appropriate to use, an if statement or a case statement? Mike55.
  5. Here is the final version of the code, it is optimised for dealing with the Malta based payment gateway endeavour: Private Function GetParameterValue(ByVal csString As String, ByVal searchValue As String) As String Dim values()() As String Dim lines() As String 'Get lines lines = csString.Split(System.Environment.NewLine) 'Use appropriate line separator 'Resize output array 'Dim i As Int16 = 0 'While i <= (lines.Length - 1) 'End While 'ReDim values(lines.Length - 1) ReDim values(0) Dim position As Int16 = 0 'Take the return and put it into a 2d array. For i As Integer = 0 To (lines.Length - 1) Select Case String.IsNullOrEmpty(lines(i).ToString) Case False 'Check to determine if the line contains valid data, some lines come back with a character with the ascii code 10 Select Case lines(i).Contains(",") Case True 'Increase the size of the array if needed. Select Case position Case 0 'do nothing Case Is > 0 ReDim Preserve values(position) End Select 'Get values for this line values(position) = lines(i).Split(","c) position += 1 Case False 'do nothing End Select Case True 'do nothing End Select Next 'In the event that the first character of the first value of each line has an ASCII value of 10, remove that character. For i As Integer = 0 To (values.Length - 1) Select Case Asc(values(i)(0).Chars(0)).ToString Case "10" values(i)(0) = values(i)(0).Remove(0, 1) End Select Next 'Begin looking for the searchValue Dim parameterValue As String = Nothing Dim aLength As Int16 = 0 Dim aHeight As Int16 = 0 Dim pos As Int16 = 0 'Get the length of the array and begin iterating though it untill parameter located. aLength = values(0).Length aHeight = values.Length While pos < aLength - 1 If values(0)(pos).ToLower = searchValue.ToLower Then parameterValue = values(aHeight - 1)(pos) Exit While End If pos += 1 End While Return parameterValue End Function Alternatively, if anyone wants to refactor the code, fire away. Mike55.
  6. dim s as string = "One, Two, Three" dim x() as string = s.Split(",") Yea, came across the above code else where and used it. I also had to use a char() to store the split elements as when I did a quick watch on the string, I found that there was also a carriage return. Given that the carriage return indicates a new line is there any way to split the string into a 2d array? Mike55.
  7. Hi all I am pooling a payments gateway looking for a response for a transaction. The payments gateway requires me to wait for 10 seconds between each pool, therefore I am considering using the following command: System.Threading.Thread.Sleep(10000) Will this work with a web page, or is there a better approach? Mike55.
  8. Hi I am using the following code to obtain a response from a web page: objRequest = System.Net.HttpWebRequest.Create(HttpPaymentRequestUrl(receiptCode)) objResponse = objRequest.GetResponse() I am using a StreamReader to convert the return into a string: Dim sr As New StreamReader(objResponse.GetResponseStream()) result = sr.ReadToEnd I want to take the result returned from the web request and put it into an array, preferabily a 2d array. Here is a sample of the web request: Here are the results that I get back: I know that I can do it by doing a loops to determine how many "," are in the string, followed by a loop that gets each value and inserts it into the array. Is there instead a more effective approach, I know that when you want to convert an array to a comma-seperated string you can use the command: String.Join(",", arrayName) Is there any method that does the reverse? Alternatively, can I use datatables? Mike55.
  9. I have 4 buttons on a page, when I click on two of the buttons, they react as per normal i.e. they go off do the relevant tasks. However, the other two buttons require that you click them either 2 or 3 times in order for them to proceed. Here is the code for one of the offending buttons: Protected Sub btnRetrieveData_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRetrieveData.Click RetrieveData() End Sub Any suggestions? Mike55.
  10. Hi all I am using the following code to download a generic file: Private Sub DownloadFile(ByVal filePath As String, ByVal fileName As String) Dim liveStream As FileStream = New FileStream(filePath, FileMode.Open, FileAccess.Read) Dim buffer(CType(liveStream.Length, Integer)) As Byte liveStream.Read(buffer, 0, CType(liveStream.Length, Integer)) liveStream.Close() Response.Clear() Response.ContentType = "application/octet-stream" Response.AddHeader("Content-Disposition", "attachment; filename=" & fileName) Response.BinaryWrite(buffer) Response.End() End Sub The file path value is: "c:\test.csv" and the file name value is: "test.csv". The problems that I am having are: When I click on the open button, the file gets opened in the web browser in a large number of occasions, on other occasions the file gets opened with excel When I click the save button, I get the following error message: I would appreciate it if anyone could help me to solve this problem or point me to a fool proof means of downloading a .csv file while allowing the user to either view or save the file. Mike55.
  11. I have the above approach working with html table, however I have been told that it needs to be able to work with panel and with absolute postion. When I allow panels, divs, etc. to be set the position: absolute I lose all control over the changeable content. Can anyone give me a valid reason on why/why not I should use absolute postions? Mike55.
  12. Found a solution, changed the code for reading the xml to Dim dsDataset As New DataSet dsDataset.ReadXml("C:\Inetpub\wwwroot\SuretxtWebSolution\Suretxt\InformationContent.xml") Dim row As Array = dsDataset.Tables(0).Select("Page='Home3'") main.InnerHtml = row(0).itemArray(1).ToString [code] and added a tag <page> to identify between collections of tags. So far the solution appears to work. Mike55.
  13. Hi all I have the following xml file <?xml version="1.0" encoding="utf-8" ?> <root> <data id="Home1"> <text> <![CDATA[ Using your web browser or mobile phone, Clubtext allows you tosend SMS <br> text messages to your customers, teams, staff, or club members in an easy<br> to use cost effective manner. <p>Clubtext includes an administrative set of features to allow you to <br> manage customer/membership details and history.]]></text> </data> <data id="Home2"> <text> <![CDATA[ This is the data that belongs to home 2. Hello world, how are you today? ]]> </text> </data> </root> In the long term there will be a lot more information and tags in this file. What I want to do is to be able to read the data from the text tag where the id of the data tag is equal to a value that I have specified. Here is the code that I am using to access the xml file and read from it: Private Sub GenerateXMLMessageBody() Dim m_xmlr As XmlTextReader m_xmlr = New XmlTextReader("C:\Inetpub\wwwroot\SuretxtWebSolution\Suretxt\InformationContent.xml") m_xmlr.WhitespaceHandling = WhitespaceHandling.None m_xmlr.Read() m_xmlr.Read() 'Load the Loop While Not m_xmlr.EOF 'Go to the name tag m_xmlr.Read() 'if not start element exit while loop If Not m_xmlr.IsStartElement() Then Exit While End If 'Get the Gender Attribute Value Dim genderAttribute = m_xmlr.GetAttribute("id") 'Read elements firstname and lastname m_xmlr.Read() main.InnerHtml = m_xmlr.ReadElementString("text").ToString End While 'close the reader m_xmlr.Close() End Sub So my question is, how can I adjust the above vb.net code so that I could in one instance specify that I want to access the text where the id of the data tag is "Home2"
  14. Thanks Jitesh, "Silly, just after figuring out what was wrong, I should be useing the command InnerHtml instead of InnerText". I am currently attempting this approach. The only problem that I am having is that the html commands such as <br> and <p> are not being recognised. I have added a div tag, given it an Id and set the runat="server". In my code behind I am using the cmd:(divtagID).InnerText = x where x is a string that contains the data returned from the text file. Any suggestion on how to get the html tags recognised? Mike55.
  15. I have a manager that wants to be able to access a site and update the description of the site that is visible to the user at any time. Can anyone suggest possible solutions, one thing that I was considering was a field in the database that holds the text that the user sees. The second option is a text file which is somehow linked to the .aspx page. Mike55.
  16. mike55

    Sitemap...

    Hi all I have to include a sitemap in my project. I am however having problems understanding what I exactly put into the sitemap. So far I have added the sitemap item to my project. What I don't understand is what exactly do you put into the sitemap, i.e. is it simply identify the various links per page, and add them as sitemapnodes under the sitemapnode for the page. Or do I just add random items to the sitemap? Mike55.
  17. Ok, the code: Request.UrlReferrer.AbsoluteUri works correctly, if I am moving from page A to B. The problem arises when I use the browser back button to go from page B back to A, or a button that I have added to the page that redirects the user back to page A. I have had a number of problems with the above command in that it does not always have a value, thus causing me problems. Mike55.
  18. Thanks for the reply MrPaul. Would love to be able to use that simple command, however, it appears not to work on all occasions. When I call it, it throws an exception, and all hell breaks loose. Mike55.
  19. Hi all I am using the following code to get the name of the previous page that the user visited: Private Function GetPreviousURL() As String Dim script As String = Nothing script &= "<script language=JavaScript id='previous'>" & vbCrLf script &= "document.referrer;" & vbCrLf script &= "</script>" & vbCrLf 'Verify script has not already been registered. If Not ClientScript.IsStartupScriptRegistered("previous") Then 'Register the script. ClientScript.RegisterStartupScript(Page.GetType, "previous", script) End If End Function [code] My only problem is that I am unsure as to how to get the value generated by document.referrer back to a vb.net variable. Any suggestions? Mike55.
  20. Solution to the https problem. Hi all This solution comes from: http://www.codeproject.com/aspnet/WebPageSecurity_v2.asp?forumid=53615&select=1770074&df=100&msg=1770074. In order to proceed you need to create a .dll that you add to your web project (I have included it in the compressed folder that I attached. Alternatively, you can go to the above site, download the source file and compile it). Once you have referenced the .dll in you web project, the next step is to open you web.config file and edit it. You begin by adding the following before the system.web opening tag: <configSections> <section name="secureWebPages" type="Ventaur.Web.Security.Configuration.SecureWebPageSettings, WebPageSecurity" /> </configSections> <secureWebPages mode="On" warningBypassMode="AlwaysBypass" bypassQueryParamName="BypassSecurityWarning"> <files> <add path="Default.aspx" secure="Ignore"/> <!-- use the same http/https as the page you are redirecting from.--> <add path="SecurePage.aspx" secure="Secure"/> <!--page has https--> <add path="nonsecurepage.aspx" secure="Insecure"/> <!--page is only http--> </files> </secureWebPages> You can also apply the https/http to an entire folder rather than single page. However, I suggest you refer to the code project site for that information, as I have not verified if that works. You then proceed and add the following inside the system.web tag: <httpModules> <add name="SecureWebPage" type="Ventaur.Web.Security.SecureWebPageModule, WebPageSecurity" /> </httpModules> Then proceed and run you project. Note inorder for this to work, you cannot have the secure communication option unticked in IIS for the individual pages. Mike55. WebPageSecurity.zip
  21. Thanks for the reply PlausablyDamp, have you ever used the above code when redirecting between http and https pages, the code seems to be running correct, but I cannot seem to get it to move between the https and http pages correctly. I am still required to manually add the "s" when moving to an https page, and the "s" remains even when I move to an http page. Has it anything to do with the fact that I am running the application on my local machine? Mike55.
  22. Thanks for the reply Nate Bross One solution that I came across, recommended creating a base page class and letting all my other pages inherit from this page. It also recommended that I should always be creating a base page class, and if I wasn't, then I am doing bad programming. The posting recommened that I should add the following code to the base page class Private _RequireSSL As Boolean <WebBrowsable(True)> _ <WebDescription("Indicates whether or not this page should be forced into or out of SSL")> _ Public Overridable Property RequireSSL() As Boolean Get Return _RequireSSL End Get Set(ByVal value As Boolean) _RequireSSL = value End Set End Property <System.Diagnostics.DebuggerStepThrough()> _ <System.Diagnostics.Conditional("SECURE")> _ Public Sub PushSSL() Const SECURE As String = "https://" Const UNSECURE As String = "http://" If RequireSSL AndAlso Request.IsSecureConnection = False Then Response.Redirect(Request.Url.ToString.Replace(UNSECURE, SECURE)) End If If Not RequireSSL AndAlso Request.IsSecureConnection = True Then Response.Redirect(Request.Url.ToString.Replace(SECURE, UNSECURE)) End If End Sub Now in my pages, I should inherit the base page class and add the following code: Partial Class _Default Inherits BasePage Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs) BasePage.OnInit(e) PushSSL() End Sub Private Sub InitializeComponent() Me.RequireSSL = True End Sub The issue that I am having is that I am getting an error for the line: BasePage.OnInit(e) and the error message that I am getting is: Any suggestions re the issue? Also what is your opinion regarding creating a base page class every time, and what should I be including in it other than the db connection code? Mike55.
  23. Hi I need to have one or two of my pages enabled with https, while the rest will all be normal http. The problem that I am having is that when I navigate to one of my https pages and then go to a non-https page, the https takes control of the non-https page. In the end, all the pages in my project are now https pages. Any recommendations, should I be typing the full address of the page I am redirecting to (request.redirect(http://www.abc.ie/subscription.aspx)) rather than just specifying the page name (request.redirect(subscription.aspx)) Mike55.
  24. I am still having the problem with the file being opened on a web browser window. I am also have the problem in that if I try to save my file I get an error message telling me that the file cannot be found. Now I have found the following code, and I have tested it on the real web server, as opposed to the test web server. The file in question opens and can be saved correctly. The issue that I am experiencing is that there is code information regarding the web page also included in the file (See attachment). Dim root As String = "C:\Suretxtlog\Templates\" Dim filePath As String = "C:\Suretxtlog\Templates\SampleCSV.csv" If Not filePath Is Nothing Then If System.IO.File.Exists(filePath) And filePath.StartsWith(root) Then Dim filename As String = System.IO.Path.GetFileName(filePath) Response.Clear() Response.ContentType = "Application/x-msexcel" Response.AddHeader("Content-Disposition", "attachment; filename=" & filename & ".csv") Response.Flush() Response.WriteFile(filePath) End If End If Any suggestions on how I can prevent this additional information being included in the file. Mike55.
  25. Going now to hang my head in shame for not spotting that. Mike55.
×
×
  • Create New...