Jump to content
Xtreme .Net Talk

cyclonebri

Avatar/Signature
  • Posts

    94
  • Joined

  • Last visited

Everything posted by cyclonebri

  1. Take it out of your global.asax. I think you are confusing application variables with session variables. A session variable, a cache variable, and a viewstate variable can be assigned or called from within any page in your application, just make sure you are using the correct one for what you are trying to accomplish. Also, if you are still having problems with your session variable, make sure your settings are correct in your web.config file and that you aren't timing out. Good Luck, Brian
  2. Hey Mike, I just built a small app that tested your question. I have found, at least on our system, that coming from a non-ssl page to an ssl page works fine if I use the fully qualified URL of the page I'm redirecting to, which places the correct qualifier in the address bar ("https://blah.blah.com/mypagetest.aspx") If you don't use the full qualifier, the address bar appears to retain the original http://blah.blah.com/mypagetest.aspx. This would be a problem if your site is secure and you don't automatically toggle your url string to https. Your best bet, if possible, would be to use the fully qualified URL, but there are articles where you can read more about these subjects if you want to try to toggle to use relative paths: These are some samples of what is out there: Setting up SSL with IIS And ASP.net Toggle between Https and Http Good Luck, Brian
  3. You can use server.transfer("URL?asdf=1&sadf=2&dasf=3") to move from one page to another without changing the visible text in the address bar. I am not sure this will work for you, however, if you are going to an app that is outside of your control (say mypage.aspx -> theirpage.aspx). You can also use hidden fields and request the hidden field on the 2nd page if you have control on the 2nd page, or session variables (again if you have control). If you can pass hidden variables outside of the query string, hidden is the best solution. If the variables must be in the query string, I would try the server.transfer. If what you are trying to do is get the three variables, post them to some url (or database) and transfer the client to another, then use server.transfer to first move to a second page in your app, execute the post, and then do the redirect. Hope that helps! Brian
  4. here is some vb code that I used to do what you are trying to do: dim sTest as string = "test" Response.Write("<script language=""javascript"">") Response.Write("try{ window.opener.document.forms[0].txtStartDate.value='" + sTest + "';}" + _ " catch (ex){alert(ex.description);}") Response.Write("self.close();") Response.Write("</script>")
  5. Glad it worked and that I could help out! I was also thinking, if you wanted to get crazy you could have the datagrid be passed into the function as well: Private Sub GridPagerVisibility(ByVal ShowHide As Boolean, byref dg1 as System.Web.UI.WebControls.DataGrid) dg1.PagerStyle.Visible = ShowHide End Sub Take Care! Brian
  6. Sure, all you need to do is add this function, and call it as you will: Private Sub GridPagerVisibility(ByVal ShowHide As Boolean) Me.DataGrid1.PagerStyle.Visible = ShowHide End Sub so you would say something like this on postback: if myFileCount < 100 Then GridPagerVisibility(False) else GridPagerVisibility(True) end if Good Luck!
  7. What exactly are you trying to do? Are you trying to save the fields in the textboxes to a text file? If so, you need to make an IO object, open a file and write the results: 'add this to the top of your project Imports System.IO '---- 'add this function and call it from your button_click event: Private Function SaveResults() As Boolean Try Dim myFile As FileInfo Dim myPath As String = "Enter_your_file_save_path_here.txt" 'delete the file if it is already there: myFile = New FileInfo(myPath) If myFile.Exists Then myFile.Delete() End If Dim mySW As New StreamWriter(myPath) mySW.WriteLine("This is the start of the results") mySW.WriteLine("VALUE 1: " + textbox1.text) mySW.WriteLine("VALUE 2: " + textbox2.text) '... mySW.WriteLine("This is the end of the results") mySW.Close() myFile = Nothing Return True Catch ex As Exception If Trace.IsEnabled Then Trace.Write("Error saving Results", ex.ToString()) Return False End Try End Function Also note -- If you are running this from an ASPX page, then you will have to have a writeable directory on your server, unless you impersonate a valid, authorized user. Good luck!
  8. In 2003 in order to access your control you need to add a reference to it, even after dragging it onto the page, by adding this to the form generated code: #Region " Web Form Designer Generated Code " ... Protected WithEvents hello as HelloWorld #End Region Then in your code you could reference the object hello.sayhello() Perhaps 2005 is similar? Good Luck!
  9. Hello All, I am having a problem related to DB2 and .Net, and was wondering if anyone could help me out. Basically, I can't connect, and I've tried many different ways. I can connect to DB2 if it's on a windows box, but the box I'm trying to connect to is a non-windows box, and is also at a remote location. What I need is to get one of two ways to work, so far I can't get either to work. The first way is using .net OLEDB and connecting via TCP/IP. The other is to use the .net Data application blocks by IBM and connect using the IP address as the server (I think I got in this way but the database name gets padded and then says it can't find it, so it errors out). Can anyone help? thanks! Sample Code: 'using oledb cs1 = "Provider=DB2OLEDB;Network Transport Library=TCPIP;Network Address=myNetworkAddress; Initial Catalog=myDB2Database;Package Collection=MyPkgCol;Default Schema=Schema;User ID=myUserId;Password=myPassword" 'using .net dab's from IBM cs1 = "Database=myDB2Database;UserID=myUserID;Password=myPassword;Server=TCPIPAddress" Thanks, Brian
  10. http://www.4guysfromrolla.com/ http://www.asp.net/Default.aspx?tabindex=0&tabid=1
  11. What are you trying to do with the label? Set some value from the class? If so, you need to add a public event in your class, and raise the event. You will also need to add an event handler on your default.aspx page, so that when the class raises the event you can have the label respond: in default.aspx, add the following code in your page load method (it needs to load each time, including post-backs: AddHandler YourClassVariable.SetLabelText, AddressOf SetLabelTextFromClass Also on default.aspx add the following method Public Sub SetLabelTextFromClass(byval newtext as string) label1.text = newtext '...whatever else you want to do on the event firing End Sub Inside your class, put the following Public Event SetLabelText(ByVal whatevertext As String) Then from whatever method inside your class that updates the text: '...inside the method RaiseEvent SetLabelText("Text set by class method x") Good Luck. If you need it to do something else, the best way to do so would be events. You could also use delegates but that is more complex and seems to have less functionality. Brian
  12. You can't send a redirect request to the response after you've sent headers to the response object for download. This causes an error: Cannot redirect after HTTP headers have been sent. (use try catch blocks in your code and enable tracing to see your code error out). There are a couple of different solutions you can try. There may be other solutions but these are the ones that come to mind. I would also be interested to see an easier solution, but i've tried all the server.transfer, server.execute, writing new response headers, embedded controls and other things that I can think of for a Friday afternoon. Anyway, you can make one of these work: 1) You can have a pop-up page which downloads the file and closes itself (simple javascript). (if you are allowed to use pop-ups). 2) You can build a web-service which allows downloads of files and call the object from your webservice within the aspx page to get files from the server without using the response headers. After the file is downloaded you can then redirect the page as expected. This is more difficult but extremely solid when completed correctly. 3) You can use an I-frame, embed the page inside of a menu page and redirect on the menu page using some sort of delegate writeback to the menu once the file is downloaded from the download page. This solution is probably the worst of the three choices IMHO.
  13. What database backend are you using, because it could make a difference in how you execute the code? You will need to use a command object, either odbc or sql and then add a parameter and set it's value for each passed in parameter, as well as it's type and size. You will therefore also need to pass in the parameter name and parameter type (int, varchar, bit, etc), as well as the size expected (i.e. 50, 4, etc), along with the parameter value and sp name (you will want to use something other than a single array I think, otherwise you will have to do some kind of parsing on the backend, or use a multidimensional array). In this manner you could set it up based on the number of records in the array. If you are using an ODBC you will also need this number to generate the (?, ?, ?, ..., ?) string for the number of parameters. Also remember that if it is an ODBC you have to specifically set the return parameter on all sp execution, whereas with sql this is not necessary. When generating the parameters you will need to be wary of the type that the parameter is supposed to be, and set it accordingly (which also brings to mind the size variable). You will also need to take into account null values and how you will handle them, because what if an sp requires 10 values but you've only passed in 7 and the other three are supposed to 'just be null?' Good Luck.
  14. When the user is clicking on the action button, is there a write to the db you could trap with the new data and determine what is being changed at this point, rather than trying to compare the two datasets after the write, or is this just a new pull from the db with some other alterations happening via a different process in the elapsed time from page-load to button push?
  15. The moon is really made of cheese... The moon is really made of cheese... When you go to the link posted above, zoom in to the maximum zoom and you will see that the moon really is made of cheese. I'd say cheddar or american. Funny stuff...
  16. VBA -- I don't know if this is exactly what you are looking for, but it is certainly possible to do something like what you are looking for. I would suggest using the xmldocument object to manipulate the xml. This code is probably not the absolute best way to do what you want, but with limited time I have wipped something up for you to look at, and you can play with the document object to do more or be more efficient if you feel so led. Anyway, I hope this will help you find a temp solution if nothing else: make sure to include the directive! [CS] //at top: using System.Xml; //inside your worker function DataSet myDS = new DataSet("results"); SqlDataAdapter myDA = new SqlDataAdapter(sqlCommand1); XmlDocument myDoc = new XmlDocument(); XmlDocument myDoc2 = new XmlDocument(); XmlElement myElement; XmlAttribute myAttribute; XmlNode myNode; string myFormerXML = ""; try { if (sqlConnection1.State!=ConnectionState.Open) { sqlConnection1.Open(); } //load the dataset myDA.Fill(myDS); //load the xml from the dataset into the xml document object myDoc.LoadXml(myDS.GetXml()); //load the old xml to string for use later myFormerXML = myDoc.OuterXml; //Create the output document with the first element here: myElement = myDoc2.CreateElement("Request"); myElement.InnerText = "RequestElementText"; myAttribute = myDoc2.CreateAttribute("FirstAttribute"); myAttribute.InnerText = "FirstAttributeText"; myElement.Attributes.Append(myAttribute); myDoc2.AppendChild(myElement); //tag the original xml into the new document here: myNode = myDoc2.CreateNode(XmlNodeType.Element, "OriginalXML", "SomeURI"); myNode.InnerXml = myFormerXML; myDoc2.FirstChild.AppendChild(myNode); //Set the final element here: myElement = myDoc2.CreateElement("Final"); myElement.InnerText = "FinalElementText"; myAttribute = myDoc2.CreateAttribute("FinalAttribute"); myAttribute.InnerText = "FinalAttributeText"; myElement.Attributes.Append(myAttribute); myDoc2.DocumentElement.AppendChild(myElement); //for fun, show the new xml MessageBox.Show(myDoc2.OuterXml); FileStream myFs = new FileStream(filename+".xml", FileMode.OpenOrCreate, FileAccess.Write); XmlTextWriter xmlWriter = new XmlTextWriter(myFs, System.Text.Encoding.UTF8); myDoc2.WriteTo(xmlWriter); ///...etc and Good Luck! :) } catch (System.Exception ex) { MessageBox.Show("ERROR: " + ex.Message); } finally { if (sqlConnection1.State==ConnectionState.Open) { sqlConnection1.Close(); } } [/CS] good luck, Brian
  17. To stress test ASP.Net apps, webservices, you can use ACT, which is included with VS.net enterprise edition. See the following articles: Microsoft ACT Web Application Stress Tool Another Article on ACT Good Luck!
  18. An excellent resource for asp.net coding, which is what I think you are asking, especially involving the datagrid control, is the website: Four Guys From Rolla More specifically, see this multipart series on the datagrid control HERE Enjoy
  19. Allright, chalk this one up to working on Saturday when it's really nice out...but, I have built a work-around, in which my web service returns the valid URL path (using a virtual directory) instead of server filepath to the file, so instead of trying to stream it, I just launch a new webpage and have that page redirect to the URL for the file which accomplishes the download/save option. Not the exact way I wanted it to work, but it is a solution. I was hoping to stream the output, maybe another time I will figure all that out. Thanks, Brian
  20. Hey everyone. I am trying to get a file to download to browser or give the option of saving to disk when selected by a user from a webpage. My issue is very simple but I cannot seem to figure out how to solve it. I have a page that is called when appropriate and passed in is a filename to download. The directory is irrelevant at this point based on how I have set up the next phase. The called page consumes a webservice which takes the passed in filename and a password, and then returns in a string the specific path to the file on the server. In this manner even the webpage is independent of the location of the files, and more obscurity is obtained for security purposes. Anyway, after all of this, my issue is that the code I'm using to try to download the file seems to be looking for the file on the client machine, and not on the server. I continue to get the 'File not found' exception, even though the file does exist on the server. If I mimic the path on the client machine, I of course do not get the error, which is how I've determined that I'm not looking at the correct machine. Is there a specific setting or chunk of code that I might be missing that would make sure the path for file download is server-side and not client-side? Here is my code: Try Dim myWFS As New WebFileShare.WebFileShare Dim source As String = Request("source") If IsNothing(source) Then Throw New Exception("ERROR: No filename passed in, cannot procede!") End If Dim filepath As String = myWFS.GetFilePath(source, myPASSWD) If Not filepath Is Nothing Then If File.Exists(filepath) Then Response.Clear() Response.ContentType = "application/octet-stream" Response.AddHeader("Content-Disposition", _ "attachment; filename=""" & source & """") Response.Flush() Response.WriteFile(filepath) End If End If Catch ex As Exception If Trace.IsEnabled Then Trace.Write("AssociatedFileDownload", ex.ToString()) End If Finally Response.Write("<script language=""javascript"">window.close();</script>") End Try Thanks, Brian
  21. For one, you didn't open your connection or new the connection object, but you may have left that code elsewhere other than this post? Are you getting any errors? Use a Try/Catch block to catch your exceptions. Also, your data adapter code is not going to work either. Check this out, substitute in what you need: Sub TestDotNetCode() 'Dim display As String 'Dim ds As DataSet = New DataSet 'Dim myconnection As SqlConnection 'display = "SELECT * FROM Student WHERE Stdcode='ST01'" 'Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter(display, myconnection) 'myDataAdapter.Fill(ds, "Student") Dim constr As String = "ConnectionStringDetailsGoHERE" Dim sql As String = "SELECT * FROM Student WHERE Stdcode='ST01'" Dim cn1 As New SqlClient.SqlConnection(constr) Try cn1.Open() Dim cmd1 As New SqlClient.SqlCommand cmd1.Connection = cn1 cmd1.CommandText = sql cmd1.CommandType = CommandType.Text Dim da1 As New SqlClient.SqlDataAdapter(cmd1) Dim ds1 As New DataSet("Results") da1.Fill(ds1) 'see if dataset exists If IsNothing(ds1) Then MessageBox.Show("Dataset does not exist") Exit Sub End If 'See if any data exists in the dataset: If ds1.Tables.Count = 0 Then MessageBox.Show("NO DATA FOUND!") Else 'make sure that item has data before trying to retrieve it: If Not IsDBNull(ds1.Tables(0).Rows(0).Item(0)) Then MessageBox.Show("DATA SAMPLE: " + ds1.Tables(0).Rows(0).Item(0).ToString()) End If End If Catch ex As Exception 'report errors: MessageBox.Show(ex.ToString()) Finally 'close connection if it exists: If Not IsNothing(cn1) Then If Not cn1.State = ConnectionState.Closed Then cn1.Close() End If End If End Try End Sub
  22. You can do one of two things: You can have the service write values to a table at intervals of say 5 minutes and then have a page that checks the table to see if the results have been updated within the last say 8 minutes or so [or just displays the top 10 entries, whatever suits your fancy]. This would tell you it's up and running. In addition, it's a good way to quickly monitor what your service has done and tracks the last time it actually did what it was supposed to do. Connecting a datagrid to the monitoring table should be a piece of cake. The other thing you should be able to do is just attach your page to the service itself (or a small executable that does this -- in addition it would have to reside on the same machine). You would also need to write some sort of response function in the service and you could have the page call that response function. Once it responds or fails to respond you can know it's working. Personally, I would go with Option 1. Good luck! Brian
  23. Jeff, I just wanted to say thank you. What you suggested works very well, and I am now able to implement the header and footer as requested. Thank you very much for pointing this method out! I much appreciate it! Take Care, Brian
  24. Hi All, I'm having some issues and I wondered if anyone else has had this problem before and if so, how to solve it. Basically, I need to make a header and footer that contain some information that will go across all of my aspx pages for this system. The problem is that the only way I've found to include a header and footer is using user controls. Creating the controls and adding them to the page is also not a problem, but there are two problems with doing things this way which I need help solving. First of all, creating a custom user control 'pads' the table that I have within the control, so that when I add it to the page there is a whitespace border around it, which I do not want (I need it flush to the top left and 100% with flush to the right. Because the user control is flow layout and cannot be changed, I cannot move the table within the design view to be flush on the top and left as I need to. IF I could do this, it would work fine, but the IDE won't let me change to grid layout for a user control, and putting a panel or other control in still remains padded with that same border. The second problem is that on resize of the control (even in an embedded table to hold the control), the control changes size and the rest of the page overlaps it, rather than the rest of the page being rendered following the bottom of the header or top of the footer. This is completely unacceptable :)! If anyone has advice on how to beat either of these problems, I would sure appreciate it. Furthermore, this must be rendered in 1.1, so using 2.0 is not an option. Thanks, Brian
  25. I actually have found the answer now. I just wanted to post it in case anyone else comes across this issue. The web link to the answer can be found HERE The answer was to change the way the sp was referenced. Instead of doing the following m_cmd1.CommandText = "s_myProcedure" I had to do the following m_cmd1.CommandText = "{ CALL s_myProcedure(?) }" Apparently the brackets, call statement, and the (?) must be necessary when using ODBC, of which I was previously unaware. Thanks! Brian
×
×
  • Create New...