|
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
|
|
|
|
|
Hi, I'm using this popup control:
http://www.codeproject.com/aspnet/asppopup.asp[^]
And I'm having a problem where someone clicks on a button on the page to make a DB update, the popup tells them it was successful. If they then click a link and go to another page, then click on the back button, the popup control fires again, even though there was no DB update the second time.
Can anyone help with a solution to this problem please?
Thanks,
Statia
|
|
|
|
|
Most likely the script for popup script is being inserted into the page during the butten click event. When using the back button this code is still in the page. You have to figure out where and how to disable it when a DB update is not necessary.
only two letters away from being an asset
|
|
|
|
|
function codename() {
if(document.formname.checkboxname.checked)
{
document.formname.textname.disabled=false;
}
else
{
document.formname.textname.disabled=true;
}
}
hi friens this is my javascript code with checkbox,button
here i select checkbox the button is enabled and deselect it is disabled(it is working fine)
now i am using html page
<asp:checkbox id="checkboxname
onclick="codename()"" runat="server">
<asp:button id="textname" disabled="" size="1" runat="server""> (it is not working)
i gave runat=server in html..(it is also not working)
can u help me
|
|
|
|
|
if you are using runat=server for any control then defin the tag like
in javascript method use like following
document.getElementById("whateverID").checked
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
If you use runat=server then the name will be changed better see in viewsource or/use
document.getElementById(CustomerInfo").Checked
or try this also
document.forms[0]["checkbox1"].checked
|
|
|
|
|
hi
it is not working
if possible give the code.plz
|
|
|
|
|
function codename() {
if(document.form[0][checkboxname].checked)
{
document.form[0][textname].disabled=false;
}
else
{
document.form[0][textname].disabled=true;
}
}
|
|
|
|
|
What exactly isnt' working? Are you getting an error?
|
|
|
|