|
They are all the same. However, they are already strings, so there is no reason to use ToString:
string test = Request.UserHostAddress;
string test2 = Request.ServerVariables["REMOTE_ADDR"];
string test3 = Context.Request.UserHostAddress;
Also:
string test4 = Context.Request.ServerVariables["REMOTE_ADDR"];
string test5 = Page.Request.UserHostAddress;
string test6 = Page.Request.ServerVariables["REMOTE_ADDR"];
string test7 = Page.Page.Request.UserHostAddress;
string test8 = Page.Page.Request.ServerVariables["REMOTE_ADDR"];
string test9 = HttpContext.Current.Request.UserHostAddress;
string test10 = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
string test11 = ((Page)(HttpContext.Current.Handler)).Request.UserHostAddress;
string test12 = ((Page)(HttpContext.Current.Handler)).Request.ServerVariables["REMOTE_ADDR"];
string test13 = ((Page)(HttpContext.Current.Handler)).Page.Request.UserHostAddress;
string test14 = ((Page)(HttpContext.Current.Handler)).Page.Request.ServerVariables["REMOTE_ADDR"];
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
when i deploy my webapplication on IIS.trying to open browse from
another machine getting HTTP:404 error
please help me
madhavi.kona
|
|
|
|
|
is your web application held locally or is it on a server?
Sounds to me like it is on a local machine
We are not a Code Charity
|
|
|
|
|
I Have created a Web Application in ASP.NET 2.0, my requirement is to get the user system information.
i.e. when the user logons to the webpage, In the home page i have to read the system information (Like OS, OSVERSION, MANUFACTURER.)..
Is it possible to do in Javascript.. If it is not possible in Javascript then is there any other way to this..??
|
|
|
|
|
Check this out:
http://www.codeproject.com/KB/system/GetHardwareInformation.aspx
We are not a Code Charity
|
|
|
|
|
the sample application i found in
"http://www.codeproject.com/KB/system/GetHardwareInformation.aspx"
is Windows application, But i need to get the information from the client machine through ASP.Net..
is it possible to execute the exe file in client machine and get the system information in asp.net 2.0
|
|
|
|
|
No I dont think you can execute a file on a user's computer using .net through your own application
try this article:
http://www.java2s.com/Code/JavaScript/Development/Getusersoperatingsysteminformation.htm
We are not a Code Charity
|
|
|
|
|
As u given the link previously wil check which OS is running in Client System..
But i need some other information Like Processor name, Model Name, etc..
Is it possible with the ActiveX components, can u guide me how to do this using ActiveX objects in ASP.Net 2.0
|
|
|
|
|
Hi
I have a CollapsiblePanelExtender1 on my page.
When the page first loads you see a flicker of what is inside it.
Is there a way to stop this/
Do I have to set my focus to another control?
We are not a Code Charity
|
|
|
|
|
sorted it, added :
Height="0px" style="overflow:hidden;"
to my panel and that stops the flicker
We are not a Code Charity
|
|
|
|
|
]]>
void validate(object source, ServerValidateEventArgs args)
{
args.IsValid = false;
}
<title>Untitled Page
<asp:button id="Button1" runat="server" text="Button">
<asp:textbox id="TextBox1" runat="server">
<asp:customvalidator id="CustomValidator1" runat="server" display="Static">
ControlToValidate="TextBox1" Text="*"
OnServerValidate="validate" ErrorMessage="CustomValidator"
SetFocusOnError="True">
|
|
|
|
|
Hi,
this is my problem: I have to create a table with unknown number of rows. There should be a button for adding a new row and a button for deleting selected rows (in each rows there is a cell with a checkbox for deleting).
How to do that? I've been trying for days, and no success...
Here is what I've done (and it's not good): in Page_Load I can see if it's a PostBack. If it is, I check which button caused it. If it is a button for adding a new row I create a row and add it to a list of rows which I save in a session. And then I call a function which takes all the rows from that list and adds it to a table. But what if I change a row in a table? I should somehow collect all the rows from the table and copy it to that session variable before PostBack, but no way to do it...
There has to be a better way to do it.
Any ideas?
Thanks.
|
|
|
|
|
|
Is it possible to do it without Ajax?
|
|
|
|
|
Try this article, its not exactly what you want but is a start
We are not a Code Charity
|
|
|
|
|
I've done something, but don't know how to finish it.
This is what I've done:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Table ID="receivingInstitutionsTable" runat="server">
</asp:Table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ButtonAddNewReceivingInstitution" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ButtonDeleteReceivingInstitutions" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
That's my table and two buttons - one for adding new row, and second for deleting selected rows. And this is inline code:
static int numberOfReceivingInstitutions = 1;
ArrayList receivingInstitutionsArrayList = new ArrayList();
protected void Page_PreInit(object sender, EventArgs e)
{
Control controlWhichCausedPostBack = GetPostBackControl(this.Page);
if ((controlWhichCausedPostBack != null))
{
if ((controlWhichCausedPostBack.ClientID.ToString() == "ButtonAddNewReceivingInstitution"))
{
numberOfReceivingInstitutions += 1;
}
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
for (int i = 0; i < numberOfReceivingInstitutions; i += 1)
{
TableRow newReceivingInstitution = getNewRow();
newReceivingInstitution.ID = "receivingInstitution" + i.ToString();
receivingInstitutionsTable.Rows.Add(newReceivingInstitution);
receivingInstitutionsArrayList.Add(newReceivingInstitution);
}
}
And that adds a row without a problem. But how to delete selected? How can I see all the data in the table to check which was selected, and how to delete them after that? Please help, it's one minute job for you and hours for me.. <i></i>
|
|
|
|
|
|
the code for this is given below:
function CmdAdd_onclick() {
var newTable,startTag,endTag;
//Creating a new table
startTag="<table id="mainTable"><tbody><tr><td></td><td style="\"WIDTH:" 120px\="">ID</td><td style="\"WIDTH:" 120px\="">User Name</td><td style="\"WIDTH:" 120px\="">Project</td></tr>"
endTag="</tbody></table>"
newTable=startTag;
var trContents;
//Get the row contents
trContents=document.body.getElementsByTagName('TR');
if(trContents.length>1)
{
for(i=1;i<trcontents.length;i++)> {
if(trContents(i).innerHTML)
{
// Add previous rows
newTable+="<tr>";
newTable+=trContents(i).innerHTML;
newTable+="</tr>";
}
}
}
//Add the Latest row
newTable+='<tr><td><input type="checkbox" name="chk" /></td><td style="\"WIDTH:" 120px\=" ">' + document.getElementById('id').value +'</td>';
newTable+='<td style="\"WIDTH:" 120px\=" ">' + document.getElementById('username').value +'</td>';
newTable+='<td style="\"WIDTH:" 120px\=" ">' + document.getElementById('project').value +'</td></tr>';
newTable+=endTag;
//Update the Previous Table With New Table.
document.getElementById('tableDiv').innerHTML=newTable;
}
function CmdDel_onclick()
{
var a = document.getElementsByName("chk");
var tbl = document.getElementById('mainTable');
var len=a.length;
var i;
var val=0;
for(i=0;i<a.length;i++)>
{
if(a[i].checked)
{
val=val+1;
if(len==1)
{
tbl.deleteRow(val);
}
else
{
tbl.deleteRow(i+1);
i=i-1;
val=val-1;
}
}
}
}
</a.length;i++)></trcontents.length;i++)>
ID:
User Name:
Project:
|
|
|
|
|
Hi,
Im displaying 10 images on the page. This images are created by a function which pics a random image from a directory on my site. However i want to make sure each of the 10 images displayed in unique / different from the other 9.
Im not sure how to do this, so i decided to create a string array. The randPic function/method is called 10 times and the returned string is stored sequentially in the array.
However i am looking for an effecient (or any) way to ensure that i dont add a string if it is already stored elsewhere in the aray.
Any help would be appreciated.
Thanks.
|
|
|
|
|
There are 2 ways to approach this. Neither are particularly hard to code
1) Pick an item at random, and check it does not already exist in the picked items. if it doesnt then add it to the picked items, if it does then pick another one. Lather, rinse repeat until you have enough items in the picked list
2) Place every item into a list and pick an item from it at random. Add this item to a selected list and remove it from the pick list. Lather rinse & repeat until you have enough items.
2) above is the more efficient way IMO, but 1) will work just fine.
|
|
|
|
|
Ok i am currently using the code below to get my random image. How could i change it to ensure i only get unique images?
<pre>
// find random image from server
string outPut = null;
string path = Server.MapPath("photographs/"+type);
string[] files = Directory.GetFiles(path);
Random r = new Random();
FileInfo fi = new FileInfo(files[r.Next(0, files.Length);]);
outPut = "photographs/" + type + "/" + fi.Name;
return outPut;
</pre>
|
|
|
|
|
munklefish wrote: Ok i am currently using the code below to get my random image. How could i change it to ensure i only get unique images?
Re-read my post above, and implement the one of your choice!
Were you expecting me to code this for you?
|
|
|
|
|
I know the theory as its quite simple. However doing it requires prior knowledge of such tasks. I dont have this hence i posted here. Thats how i thought help forums worked.
Normally people give some sort of help with coding and/or links to relevant info.
Thanks anyway.
|
|
|
|
|
munklefish wrote: Normally people give some sort of help with coding and/or links to relevant info.
hmm.. such as outlining exactly the process you need to follow to accomplish a task. Im sorry we don't hand-hold here.
If you give it a try, and run into difficulties post some code and someone will surely help. However, we dont write code for you...presumably you're being paid to write this code. If you want me to write it, i'll want paying!
|
|
|
|
|
Actually its a project for myself. But sorry to waste your time.
|
|
|
|