|
seemamltn wrote: It gives me error
That's nice. It's usually more helpful to include the error when asking for help.
In this case however it isn't necessary. You are trying to use a server method (Response.Redirect) from the client side in your Javascript. It won't work.
only two letters away from being an asset
|
|
|
|
|
|
Hi itsbijusamuel.
Is it possible making a javascript for server side using runat="server".
surprise??????
Bajrang Singh
Using .net 2.0 (VS2005)
|
|
|
|
|
I am building a shopping cart type web application. There are two web forms. The first web forms allows a user to select products. The second allows a user to enter quantities for each product selected in the first web form. I use a disconnected datatable to maintain and update selected products and quantities.
The problem is that the datagrid drops any quantity values entered by the user(there is only 1 input TextBox for each row in the datagrid). The code-
foreach(DataRow dr in dtShoppingCart.Rows)
{
if(((TextBox)dataGridItem.FindControl("txtSKU")).Text.ToString() ==
dr["SKU"].ToString())
{
dr["Quantity"] = ((TextBox)dataGridItem.FindControl ("txtQuantity")).Text.ToString();
break;
}
}
Any ideas?
|
|
|
|
|
Databinding is happening on the grid as it is being reposted to handle, which restores the textboxes to the original state.
Look at the Checkboxes and Textboxes section
http://www.codeproject.com/aspnet/datagriddemo.asp[^]
only two letters away from being an asset
|
|
|
|
|
Thanks. Looking at it now.
|
|
|
|
|
For the most part that makes sense. Currently I am using a datatable. Do I update the rows in the datatable in the OnQtyChanged method and then rebind that to my datagrid? Does the OnQtyChanged method a replacement for the onclick event I am using now?
|
|
|
|
|
wood0601 wrote: Do I update the rows in the datatable in the OnQtyChanged method and then rebind that to my datagrid?
Yes
wood0601 wrote: Does the OnQtyChanged method a replacement for the onclick event I am using now?
No
only two letters away from being an asset
|
|
|
|
|
Hey,
I am trying to place some plain text/html on my .net web page using the code behind page but I can't seem to do it.
Response.Write justs puts any text at the very top of my page and I can't work out if I have to use panels, placeholders or anything else to do the job. I can put a panel where I want it but the text is generated on the page load and needs to be postioned from there - or written into the relevant control, but I just cant work it out.
Can someone please help?
thanks
|
|
|
|
|
Use a control, such as label, and position it where you would like. Then in the code-behind set the text as appropriate.
only two letters away from being an asset
|
|
|
|
|
ok, that would be fine but...
I'm generating a written list of files within a specific folder that will need to be written to the page in the form of hyperlinks, each one having a different querystring attached.
As the folder and number of files change, I will not know how many individual lines I will need to write and would need to put each line in a new lable (correct me if i'm wrong, its a regular occurance).
any further suggestions?
thanks for the response
|
|
|
|
|
Use a repeater control. It can be bound to a list, such as the list returned from System.IO.Directory.GetFiles(). Then using databinding expression, or handling the events, the hyperlinks can be formatted as necessary. This will allow for flexibility in the number of items displayed and isolate the logic for obtaining the items.
only two letters away from being an asset
|
|
|
|
|
yey it worked!!
thank you very much for your help
I can go take some headache pills now
|
|
|
|
|
Hi currently the above application allow multiple widget instance in a column dropcue in top to bottom order.
I would like to find out anyway to restrict the number of widget appearing in a column to one only? This also means that the dropcue display will appear only when the column is empty and will not appear when the column already have one widget on it. thanks in advance!! help help!
cheers
|
|
|
|
|
Is it possible to have two grids next to each other on a page and synch
them to where if you horizontally scroll one grid, the other also scrolls? I have found some javascript code that is suppose to help but my javascript isn't the strongest so if you can point me in the right direction to if this code should workk and where to put it that would be great I have tried several options but to no avail I can't get it working. Thanks for any help.
|
|
|
|
|
What problem do you face
when you place both the Grids in a single Panel?
I think it will solve your problem.
Regards,
Arun Kumar.A
|
|
|
|
|
I have to keep the panels seperate. The problem I have is where actually to put the code in order to see if it will work or not. Otherwise I will just scrap it.
|
|
|
|
|
I would expect that the code should go at the top of the .aspx page.
If it does not work there then it could be that
needs to be:
as doScroll is the name of the second function?
As far as I can see that should work
|
|
|
|
|
This the code to initialize a button control that I have on my page:
Sub Page_Load(ByVal Sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
SQLconn.Open()
Dim SelectCmd1 As New SqlCommand("SELECT [rawvalue] FROM [Data] WHERE (timestamp=(SELECT MAX(timestamp) FROM [Data]WHERE(name = 's1'))) AND (name='s1')", SQLconn)
SelectCmd1.CommandType = CommandType.Text
Dim result1 As Integer
Dim myDataReader1 As SqlDataReader
myDataReader1 = SelectCmd1.ExecuteReader()
myDataReader1.Read()
result1 = myDataReader1.GetInt32(0)
SQLconn.Close()
ChangeButton1(result1)
End If
End Sub
Sub ChangeButton1(ByVal Status As Integer)
If Status = -1 Then
Label1.Text = "ON"
OnOff1.Style.Value = "background-image: url(../ImgContr/1.png);"
Else
Label1.Text = "OFF"
OnOff1.Style.Value = "background-image: url(../ImgContr/2.png);"
End If
End Sub
Also I use to write to the database:
Sub OnOff_Click1(ByVal Sender As Object, ByVal e As System.EventArgs)
Dim updateCMD As SqlCommand
Dim query As String
If Label1.Text = "ON" Then
query = "UPDATE [Triggers] SET [rawvalue] = 'False' WHERE [name] = 's1'"
ChangeButton1(0)
Else
query = "UPDATE [Triggers] SET [rawvalue] = 'True' WHERE [name] = 's1'"
ChangeButton1(-1)
End If
updateCMD = New SqlCommand(query, SQLconn)
updateCMD.CommandType = CommandType.Text
SQLconn.Open()
updateCMD.ExecuteNonQuery()
SQLconn.Close()
End Sub
I used Ajax Update Panel with my button(OnOff1) inside to write the to the database without reloading the page.
What I want now is to poll the database every few seconds to read the values without pressing refresh(F5).
I believe that I have to use the Ontick event of the Update Panel Trigger and a asp Timer control.
How should I modify the Sub for Page_Load Event?
|
|
|
|
|
You need to write some javascript. Use the setInterval function to call your server-side method and get the refreshed data. Then you can refresh the control used to display your data.
Another tip: Stop using dynamic SQL statements! Use stored procs ro at least validate the values used to build your statements.
only two letters away from being an asset
|
|
|
|
|
Do you have any examples for the javascript?
I will use dynamic SQL statements only for testing.
Thank you for your tips.
|
|
|
|
|
kallileo wrote: I will use dynamic SQL statements only for testing.
Yeah, I've heard that many times.
So you plan on writing two different versions of your code, one for testing and one for production? Can we guess at how reliable and maintainable that solution will be.
As for the javascript, do a search for setInterval
only two letters away from being an asset
|
|
|
|
|
It's for presentation only. I'm a student and I neen it as a Interface to control a hardware device in my project.
Is javascript realy necessary?
I was thinking of using asp timer control with an interval and the OnTick event of the triggers in the update control to call the Sub to refresh the page.
Thank you.
|
|
|
|
|
kallileo wrote: I'm a student
Then you should be learning the proper way to code.
kallileo wrote: Is javascript realy necessary?
AJAX = Asynchronous JAVASCRIPT and xml
At some point if you are using AJAX you will need to learn it. No it isn't strictly necessary in your case, although I think it is easy to use then what you trying.
-- modified at 11:52 Tuesday 12th June, 2007
only two letters away from being an asset
|
|
|
|
|
Dear all,
I am using Visual Studio2005.
Everything was working fine till I tried to set default error page for web application
(that is through ASP.NET Configuration I used ->application tab, set default error page)
Then after I am getting stating Unable to start Debugging on the web server
I restart iis and even reinstall the IIS problem continue.
Please help
thanks
regards
imran khan
|
|
|
|