
lamy
Avatar/Signature-
Posts
56 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by lamy
-
as an alternative for popup i made a script to make a DIV visible/hidden and place whatever page i needed to popup in its InnerHTML, the scripts works and now i wanted to make it a control so i dont have to paste/embed the code whenever i need to heres what i have, on the HTML part, i placed the DIV and script that i needed <script language="javascript"> function Show(url) { var frm = document.getElementById("MyDiv"); frm.style.visibility = "visible"; frm.innerHTML = "<iframe src='" + url + "' ID='MyIFrame'></iframe>" } function Hide() { var frm = document.getElementById("MyDiv"); frm.style.visibility = "hidden"; } </script> <DIV id="MyDiv" style="position:absolute; visibility:hidden"> </DIV> in my web form i have 2 buttons, one to hide it and the other to show the frame <ASP:Button ID="btnHide" runat="Server" Text="Hide" /> <ASP:Button ID="btnShow" runat="Server" Text="Show" /> in my code behind i added the onClick attributes to my buttons Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load btnHide.Attributes.Add("onClick", "Hide()") btnShow.Attributes.Add("onClick", "Show('something.aspx')") End Sub so everything is working, except that i wanted to make that DIV move along as i scroll the page, to do that i needed to add some script function Move(source) { var frm = document.getElementById("MyDiv"); var offset = 0; // nothing to move if (frm.style.visibility == "hidden") return; // IE compatible if (document.all) offset = source.scrollTop; else offset = document.body.scrollTop; frm.style.top = frm.style.height + offset; } and that requires an additional attribute to my body <body onMouseMove="Move(this)"> question 1: now, how do i set an attribute for my body in my usercontrol? question 2: is it possible to make my DIV ID (MyDiv) as property, how? question 3: and how do i set the properties of that DIV (say background, etc.) i made a test web usercontrol and was able to get/set its properties Private Something as String = String.Empty <Personalizable()> _ Public Property MySomething() As String Get Return Something End Get Set(ByVal value As String) Something = value End Set End Property one way i could think of (havent tried though) is to render (Response.Write) an HTML with the values of each properties but dunno if itll do what i needed was thinking of using it as popup and using it for my date picker aswell, anyone?
-
dunno whats causing this, i just went out to lunch and suddenly when i loaded my project it keeps showing this error "The state information is invalid for this page and might be corrupted." anyone has a list or something that might cause this so i could check each? for now im gonna try the solution from microsoft (generate a specific machine key)
-
due to security restriction close method only works if it is opened by javascript using open method, else it will prompt to close the window you can try using self.close http://www.javascript-coder.com/window-popup/javascript-window-close.phtml i tried doing the same thing with the response.write but it somehow fails, one workaround is to load something like an image and add an attribute to it "onBlur" to trigger your javascript
-
sqlparametercollection as function argument
lamy replied to lamy's topic in Database / XML / Reporting
i was able to resolve it, seems that i throws an exception if i dont put a value to it so i set a value to it param.Add("@retval", SqlDbType.VarChar, 15).Direction = ParameterDirection.Output param("@retval").Value = String.Empty after testing Joe's post i made some changes to my codes, no need to create a new instance of SqlParameter, and the code is much shorter :D For Each p As SqlParameter In param .Parameters.AddWithValues(p, param(p)) Next -
tnx bri189a, yea i think AJAX would be my last resort ;)
-
sqlparametercollection as function argument
lamy replied to lamy's topic in Database / XML / Reporting
thanks Igor Sukhov and Joe Mamma, im trying out joe's post Imports System Imports System.Data.SqlClient Imports System.Collections.Generic Private Class ParamDictionary Inherits Dictionary(Of String, Object) End Class Private Sub Test() Dim param As New ParamDictionary() param("@Branch_ID") = "something" execSP("spTest", param) End Sub private Sub execSP(ByVal spName As String, ByVal param As ParamDictionary) Dim com As New SqlCommand With com ... suppose theres a connection ;) .CommandType = CommandType.StoredProcedure .Parameters.Clear() For Each p As String In param.Keys .Parameters.AddWithValues(p, param(p)) Next ... execute and return goes here (if as a function) End With End Sub but what if i wanted to set a size for each parameter and hows about a parameter output (direction)? anyway, my first try works but i couldnt figure out how to pass a parameter as an output direction this doesnt work param.Add("@retval", SqlDbType.VarChar, 15).Direction = ParameterDirection.Output -
sqlparametercollection as function argument
lamy replied to lamy's topic in Database / XML / Reporting
i did some changes, i got it working now, but i wonder if theres an alternative to this heres the changes: 1 - adding the parameter (value doesnt show, wrong argument column, eheheh) param.Add("@Branch_ID", SqlDbType.VarChar, 6).Value = Session("branch_id") 2 - parsing the collection and assigning it to command parameter (resolves the exception) For Each p As SqlParameter In param Dim par As New SqlParameter With par .ParameterName = p.ParameterName .SqlDbType = p.SqlDbType .Size = p.Size .Value = p.Value End With .Parameters.Add(par) Next -
thanks Igor, i guess ill set aside the lazyness and code each variable. ;)
-
was thinking of putting something like this in my class :D Private Sub Test() Dim sqlCmd As New SqlCommand Dim param As SqlParameterCollection = sqlCmd.Parameters param.Add("@Branch_ID", SqlDbType.VarChar, 6, Session("branch_id")) execSP("spTest", param) End Sub Public Sub execSP(ByVal spName As String, ByVal param As SqlParameterCollection) Dim com As New SqlCommand With com .CommandType = CommandType.StoredProcedure .Parameters.Clear() For Each p As SqlParameter In param .Parameters.Add(p) Next ... End With End Sub but it gives this exception "The SqlParameter is already contained by another SqlParameterCollection." anyone? :confused:
-
so using datatable is a little slower?
-
the need to do client-side arised when the list of product generated almost a 75-100KB HTML code (not a problem with broadband but dial-ups still exist) with the tables along with the data, since the transaction page requirement is to display every product categorized with its needed inputs (i would have done pagination if it wasnt for the requirement), not to mention having a lot of buttons with different functions (which will tend to postback on mouse click, thus, reloading the page over and over), the existing system actually does postback so often that youll notice it, and thats one of the clients main concern, we did suggest redoing the GUI so it would be rendered at less time and more userfriendly, but unfortunately they didnt want to keep it as is (i guess they didnt want to confuse the user, and also less training). do you mean something like using <input type="button" ... > instead of <asp:Button ...>, i tried doing that but it kept posting back (even the onClick's attribute in other objects), i guess ill give it another try.
-
was wondering if there would be any difference between literal values and datatable placed in a session, suppose i have these Session("object1") = "the string" Session("object2") = 100 Session("object3") = True and these Dim dt As New DataTable("objects") Dim dr As DataRow dr = dt.NewRow With dr .Item("object1") = "the string" .Item("object2") = 100 .Item("object3") = True End With dt.Rows.Add(dr) Session("objects") = dt would it differ in performance? (probably will) what could be the best practice? (in general), just curious
-
:D oops, i think that made it a little complicated for me the radiobuttons resides in different table rows in my table control, as a workaround i used ID since itll have the same value as my Value row = New TableRow col = New TableCell radio = New RadioButton with radio .GroupName = "myRadioButton" .ID = "myValue" .Text = "myDescription" end with col.Controls.Add(radio) row.Cells.Add(col) myTable.Rows.Add(row) since im changing it to RadioButtonList how do i insert it to my table control (displaying it in different table rows per item) radio = New RadioButtonList With radio .ID = "myRadioButton" .Items.Add(New ListItem("myDescription", "myValue")) End With the HTML that i intend to render is something like this <table> <tr> <td colspan="2"> Something goes here like category or brief description </td> </tr> <tr> <td> </td> <td> <input type="radio" name="myRadioButton" value="myValue"> myDescription </td> </tr> .. </table> there are some rows that has textbox in it depending on the value of the radio or even other controls, thats why i needed it on a separate table row.
-
also if you wanted to fire up a javascript function as you click a button you would have to add an attribute to it Sub Page_Load() yourButton.Attributes.Add("onClick", "doThisFunction()") End Sub
-
thanks bri189a for the answers as well as for the advice, i know im complicating things but the reason why im doing it like so is that i needed this single page not to reload itself (postback which it naturally does), which is a transaction page that has a lot of data written to it, so to make it faster (which is mainly the requirement) i needed it to do most part to client-side instead.
-
thanks again bri189a, i guess ill be re-doing some stuffs, anyway its doing fine with the workaround since it all falls to a simple radio form object when it comes to html, but just to be safe i am re-coding ;)
-
in my javascript i have this function submitToFrame(url) { var frm = document.forms[0]; frm.target = "myIFrame"; frm.action = url; frm.submit(); return false; } and a submit button with this attribute Sub Page_Load() btnSubmit.Attributes.Add("onClick", "return submitToFrame('page.aspx');") End Sub clicking the button would cause this error in the target page Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. i have several buttons which has different functions, and im doing most of the task on client-side since i intend to use this for transaction with lots of data so i cant rely on postback, except for my final submit anyone? :confused:
-
thanks again bri189a, that made my codes shorter than using a literalcontrol, but i cant figure out how to set the value of the radiobutton, cant find any .Value in my properties. what i did is changed the value of ID instead, and set my GroupName so i could still check it as one (i think), but i still havent tried accessing the value after the postback, obviously i couldnt use the GroupName yet, so ill probably use a .FindControl, but would it work with GroupName, since my ID is no longer the same as GroupName.
-
you dont have to click the button to fire up something, if your button fires a submit then submit it using javascript (document.forms[0].submit()), but if your button calls a function then call the same function in your javascript.
-
tnx bri189a
-
saw the problem, its in DOCTYPE tag, i guess id have to find a way to make it compatible, as a work around, i removed the DOCTYPE tag.
-
the ASPX page is almost the same except for the head part <%@ Page Language="VB" AutoEventWireup="false" CodeFile="WebForm1.aspx.vb" Inherits="WebForm1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>WebForm1</title> </head> <script language="javascript"> function moveDIV(source) { var frame = document.getElementById("floatingDIV"); var offset = 0; // IE compatible if ((document.all?true:false) == true) offset = source.scrollTop; else offset = document.body.scrollTop; frame.style.top = offset; } </script> <body OnMouseMove="moveDIV(this)"> <div id="floatingDIV" style="position:absolute"> This is the floating DIV </div> <p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p> <p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p> </body> </html>
-
i have a floating DIV tag which moves along with the page, already tested it on modern browsers (with .HTM as extension, tested with IE6, NS8, Opera 8, Firefox 1.5 and Safari 1.x), it was working but it doesnt when i inserted the same code in my ASPX page. heres the same html page im using <html> <script language="javascript"> function moveDIV(source) { var frame = document.getElementById("floatingDIV"); var offset = 0; // IE compatible if ((document.all?true:false) == true) offset = source.scrollTop; else offset = document.body.scrollTop; frame.style.top = offset; } </script> <body OnMouseMove="moveDIV(this)"> <div id="floatingDIV" style="position:absolute"> This is the floating DIV </div> <p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p> <p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p> </body> </html> there seems to be a problem with document.getElementById but it is client-side, it shouldnt affect my ASP.Net page or theres something that i should be doing to make it work, anyone?
-
thanks bri189a, how do i get its properties after posting back? is it the same as the dragged controls?