|
|
Thanks for the prompt reply!
I tried this before, seems like all went fine except the page is shown empty.
As I explained before, not sure if it makes any difference, I am using a user control (ascx) in a web page (aspx).
Following is the code I used:
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
if (!Page.IsPostBack)<br />
{<br />
DataTable myDt = CreateDataTable();<br />
Session["myDatatable"] = myDt;<br />
<br />
this.GridView1.DataSource = ((DataTable)Session["myDatatable"]).DefaultView;<br />
this.GridView1.DataBind();<br />
}<br />
}<br />
<br />
private DataTable CreateDataTable()<br />
{<br />
DataTable myDataTable = new DataTable();<br />
<br />
DataColumn myDataColumn;<br />
<br />
myDataColumn = new DataColumn();<br />
myDataColumn.DataType = Type.GetType("System.String");<br />
myDataColumn.ColumnName = "id";<br />
myDataTable.Columns.Add(myDataColumn);<br />
<br />
myDataColumn = new DataColumn();<br />
myDataColumn.DataType = Type.GetType("System.String");<br />
myDataColumn.ColumnName = "username";<br />
myDataTable.Columns.Add(myDataColumn);<br />
<br />
myDataColumn = new DataColumn();<br />
myDataColumn.DataType = Type.GetType("System.String");<br />
myDataColumn.ColumnName = "firstname";<br />
myDataTable.Columns.Add(myDataColumn);<br />
<br />
myDataColumn = new DataColumn();<br />
myDataColumn.DataType = Type.GetType("System.String");<br />
myDataColumn.ColumnName = "lastname";<br />
myDataTable.Columns.Add(myDataColumn);<br />
<br />
return myDataTable;<br />
}
And thanks again.
|
|
|
|
|
All you did there was add columns to the datatable, now try adding rows to it:
myDataTable.Rows.Add("XXXXX", "TCP", "XXXXX", "XXXXXX")
That should get you started.
|
|
|
|
|
Thanks Matthhews!
It did work, but I thought columns are created even when no data is inserted.
Is there a way to force that happen?
|
|
|
|
|
When you create a column, all your doing is making a place to "store" that data in the datatable. You'll still need to create the data to populate it with.
|
|
|
|
|
Thanks!
Still not able to do one thing:
I am creating the GridView, taking the data from a datatable and it is showing just fine.
When I am trying to add few more rows later (depending when I got a trigger from a client), it is not showing up.
Following is my code:
UC1.ascx
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
if (!Page.IsPostBack)<br />
{<br />
myDataTable = new DataTable();<br />
CreateDataTable();<br />
Session["myDatatable"] = myDataTable;<br />
<br />
this.GridView1.DataSource = ((DataTable)Session["myDatatable"]).DefaultView;<br />
this.GridView1.DataBind();<br />
}<br />
}<br />
<br />
public void CreateDataTable()<br />
{<br />
DataColumn myDataColumn;<br />
<br />
myDataColumn = new DataColumn();<br />
myDataColumn.DataType = Type.GetType("System.String");<br />
myDataColumn.ColumnName = "IP";<br />
myDataTable.Columns.Add(myDataColumn);<br />
<br />
myDataColumn = new DataColumn();<br />
myDataColumn.DataType = Type.GetType("System.String");<br />
myDataColumn.ColumnName = "Port";<br />
myDataTable.Columns.Add(myDataColumn);<br />
<br />
myDataColumn = new DataColumn();<br />
myDataColumn.DataType = Type.GetType("System.String");<br />
myDataColumn.ColumnName = "Command";<br />
myDataTable.Columns.Add(myDataColumn);<br />
<br />
myDataColumn = new DataColumn();<br />
myDataColumn.DataType = Type.GetType("System.String");<br />
myDataColumn.ColumnName = "Data";<br />
myDataTable.Columns.Add(myDataColumn);<br />
<big> !!!!!! This one works fine and shows up correctly !!!!!!!!</big><br />
myDataTable.Rows.Add("IP", "Port", "Command", "Data");<br />
}<br />
<br />
<big>Calling this will have no effect, why???</big><br />
private void AddDataToTable(string Ip, string Port, string Command, string Data)<br />
{<br />
DataRow row;<br />
row = myDataTable.NewRow();<br />
<br />
row["IP"] = Ip;<br />
row["Port"] = Port;<br />
row["Command"] = Command;<br />
row["Data"] = Data;<br />
<br />
myDataTable.Rows.Add(row);<br />
this.GridView1.DataBind();<br />
}<br />
Do not understand why calling AddDataToTable makes nothing.
|
|
|
|
|
Is there a way to open a folder in windows explorer with a Vista Gadget?
I succesfully created the gadget (which lists my current projects and has a hyperlink to the folder containting the relevant documents), but the sidebar blocks popups. I even tried to launch the explorer via the exe, but that's blocked as well.
I found something with VBScript for an alert box, but I couldn't find an example for a popup (hyperlink).
Thanks for any assistance.
|
|
|
|
|
I have a drop down selection box with items in it. I need to be able to pass the selected item through using an onclick event for the "Submit" button. Is this possible?
I have a JavaScript that is calling a div to popup. This div is the drop down selector. I want the user to click a button to make the drop down appear, then they must select an item in the list and then hit submit. The submit button being clicked I need to bring in the selected value from the drop down and use it in the script that originally told the div to pop up (this is the first button that the user clicks, it actually runs the script which passes 2 variables, and is basically waiting on the drop down selection to save into a 3rd variable, which will then call a PageMethod).
I have
function AddTemplateToUUT(uutnumber,testerid){
var templatename=SelectTemplateToAssign();
PageMethods.AddTemplateToUUT(testerid,uutnumber,templatename,CallbackDiv,CallbackErrorAlert,'divchecklistarea');
}
function SelectTemplateToAssign(){
ShowSelection('divtemplateblock','show');
var tname=document.getElementById('drptemplateselect').value;
alert(tname);
ShowSelection('divtemplateblock','hide');
return (tname);
}
Anyone please help?
|
|
|
|
|
<html>
<head>
<style type="text/css">
#yourDivID {
visibility: hidden;
display: none;
}
</style>
</head>
<body>
<div id="yourDivID">
<select>
<option value="1"> One </option>
<option value="2"> Two </option>
</select>
</div>
<input type="button" onclick="document.getElementById('yourDivID').style.visibility = 'visible'; document.getElementById('yourDivID').style.display = 'block';" value="Click me!" />
</body>
</html>
Does that help?
|
|
|
|
|
Sort of. Remember that the first button is not an input type, it's just an href to a javascript because it HAS to have 2 parameters passed to it. That javascript needs to get this third value from the drop down in order to send all 3 parameters to a PageMethod.
Here it looks like You made a "Click Me" that pops open the div, I assume waits for the selection, then closes it?
|
|
|
|
|
Hello!
I have been asked to develop user authentication for a lan site based on a certain dll that will be provided - I have no ideia where to start. Would someone be kind enough to provide any tips or tutorials or examples regarding dll based authentication in classic ASP?
I reckon its a pretty vague question, but I've been looking into ISAPI based authentication and I still have no clue.
Thanks in advance,
|
|
|
|
|
Hi,
I'm getting desperate. I've tried an amazing combination of header commands to get IE8 to prompt a file dialog box for a known or unknown MIME type.
I've spent a lot of time researching this and I still can't get anything that IE8 likes without hanging. My code works fine in Google Chrome, Mozilla and Firefox...
Does anyone know how to get this to work in IE8?
I've tried this:
protected void Page_Load(object sender, EventArgs e)
{
Download(Session["Arquivo"].ToString());
}
private static void Download(string mCaminho)
{
byte[] docByteArray = StreamFile(mCaminho);
FileInfo doc = new FileInfo(mCaminho);
using (MemoryStream ms = new MemoryStream(docByteArray))
{
long dataLengthToRead = ms.Length;
int blockSize = dataLengthToRead >= 5000 ? 5000 : (int)dataLengthToRead;
byte[] buffer = new byte[dataLengthToRead];
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("Pragma","public");
HttpContext.Current.Response.AddHeader("Cache-Control","no-store, no-cache, must-revalidate");
HttpContext.Current.Response.AddHeader("Cache-Control","post-check=0, pre-check=0");
HttpContext.Current.Response.AddHeader("Content-Description","File Transfer");
HttpContext.Current.Response.AddHeader("X-Download-Options","noopen");
HttpContext.Current.Response.AddHeader("X-Content-Type-Options","nosniff");
HttpContext.Current.Response.AddHeader("Content-Transfer-Encoding","binary");
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + doc.Name);
HttpContext.Current.Response.AddHeader("Content-Length", doc.Length.ToString());
HttpContext.Current.Response.ContentType = TipoArquivo(doc.Name);
while (dataLengthToRead > 0 && HttpContext.Current.Response.IsClientConnected)
{
Int32 lengthRead = ms.Read(buffer, 0, blockSize);
HttpContext.Current.Response.OutputStream.Write(buffer, 0, lengthRead);
dataLengthToRead = dataLengthToRead - lengthRead;
}
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
}
HttpContext.Current.Response.End();
}
private static String TipoArquivo(String mArquivo)
{
String mContentType = String.Empty;
switch (Path.GetExtension(mArquivo))
{
case ".pdf":
mContentType = "application/pdf";
break;
case ".xls":
mContentType = "application/vnd.ms-excel";
break;
case ".doc":
mContentType = "application/doc";
break;
case ".xlsx":
mContentType = "application/vnd.ms-excel";
break;
case ".docx":
mContentType = "application/msword";
break;
case ".rtf":
mContentType = "application/rtf";
break;
case ".txt":
mContentType = "text/plain";
break;
case ".zip":
mContentType = "application/zip";
break;
case ".xml":
mContentType = "application/xml";
break;
}
return mContentType;
}
private static byte[] StreamFile(string filename)
{
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
byte[] ImageData = new byte[fs.Length];
fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
return ImageData;
}
|
|
|
|
|
I don't have IE8. However assuming IE8 works correctly when you use it to download a file, like a zip code file from a CodeProject article, then you can write your own client (or just use a telnet session) and send the server the IE8 Agent header information and look at the HTTP response it sends back that works in IE8. I mean can't you?
|
|
|
|
|
The culprit is the no-cache header. To fix it remove the following line:
HttpContext.Current.Response.AddHeader("Cache-Control","no-store, no-cache, must-revalidate");
Please refer to the following Microsoft KB article for more info:
http://support.microsoft.com/kb/316431[^]
Good luck,
Sonny
|
|
|
|
|
Hello,
I've come across an article on placing PHP environmental variables into Apache logs.
I'd prefer to code with apache_setenv() and apache_getenv(), but I'm curious if anyone has experience with this method over using apache_note()? Are there any security concerns with one over the other?
Any input is appreciated.
Thanks,
Matt
|
|
|
|
|
EDIT: Found the solution to the problem. I used method 1. I nested the navigation bar in a DIV and the content holder in another DIV already, so all I did was set the bottom padding of the navigation's DIV long enough to nest the hover menu as it drops. I then adjusted the contentholder's top margin to a negative value so that the menu could overlap on hover. Hm I might write a tutorial over the summer about how to make a hover menu without a defined width so that the listed items' boxes all align to the width of the item with the maximum width automatically (the menu having no dependancy on it's parent's width). Btw, only tested with FF, IE7/8 and the lastest version of safari. Will test on Opera as well before posting; maybe IE 6 if people still care about it :P.
Another way was to just change the position of the nav bar's div to absolute but that makes things too messy. Much rather be lazy with the margin's solution and not spend ages fiddling about to make it look exactly the same on most browsers.
-------------------------------------------------
Hi guys,
I've been experimenting a way of creating horizontal drop down menus without defining a specific width. I found a solution in the end which works for IE8 and Firefox, but no surprise, IE 7 plays up. Trying to solve for IE7 has left me in two situations:
1) The first method uses:
ul#nav li:hover ul
{
display:block;
position:absolute;
padding-top:0px;
padding-left:0px;
padding-right:0px;
padding-bottom:0px;
margin-left:0px;
}
this is combined with a float:none in the sorted list held in the unested list (above) i.e ul#nav li:hover ul li . This method works fine in IE 8 and Firefox. I like this method because the hover menu is not limited to the relative width of its parent list. The problem with this method is, on IE 7, for some reason, as I try to hover over the lower list items, the hover menu dissapears and i suspect this has to do with the hover menu overlapping the text and being at a z-index value furthur behind. I tried to bring the z-index value of the hover menu forward but didn't have much luck with that.
second method:
the second method simply uses the old fasioned position:relative to nest the hover menu. I have kept the width undefined, and so long named anchors in the hover menu are not scrunched up! The problem with this method basically is the reverse of the first method. The hovering works fine but now the parent list keeps resizing its length to the maximum width of the child list (if it's wider than the parent list). Furthurmore, the nice floating effect has gone (but i reckon this could easily be fixed).
I have come here to ask if anyone knows a solution to either method. if all else fails i guess i could resort to specific element ids again...
Thanks,
Arroci
modified on Wednesday, June 24, 2009 9:27 AM
|
|
|
|
|
Hi everybody
I'm trying to save image from webBrowser control which I have in my project. I could do it by right clicking on the
image and selecting "Save Picture As..." context menu, except I wanted to do it programmatically.
I found a solution like this:
this->webBrowser1->Document->execcommand("Save As", false, strFilePath); but it doesn't work (it always show save as dialog box - I do not want a save as dialog box to show up).
Some one has better idea?
|
|
|
|
|
I have a .aspx page that has 2 javascript calls on it. They worked previously and now are broken. Through Firefox's web development addon, I am getting errors like:
ToggleDetail is not defined
TesterDetail.aspx?name=xxx
I have checked everything I can think of 100 times over:
1) My .aspx page has a ScriptManager with
path="testerdetail.js"
in it.
2)My testerdetail has the correct spellings of the functions being called.
3)The number of parameters in the call and declaration match
What am I missing, why is this happening?
Here is one of the functions with issues in JavaScript:
function OpenChecklistForm(id,uut){
window.open('ChecklistForm.aspx?UUT='+uut',&tid='+id'_blank''scrollbars=yes,resizable=yes');
}
With an error from Firefox web dev kit saying "Missing ) after argument list", but points to the single quote after uut in the window.open call.
modified on Tuesday, June 23, 2009 4:14 PM
|
|
|
|
|
Here's your problem. ,&tid='+id'_blank''
Make sure you are creating a valid string and passing in the correct arguments to window.open
|
|
|
|
|
hi all,
i'm trying to use javascript funtcion 'javascript:window.print();' to print current webpage.
the problem that i lose all my color font, layout when i do the print.
is there something to add to CSS to print the same page as it is shown on screen ?
Thank you for helping me
|
|
|
|
|
Make sure the CSS you're using isn't scoped to just the 'screen.' If it is, you'll have no stylesheets while printing
|
|
|
|
|
<style type="text/css" media="print">
</style>
<style type="text/css" media="screen">
</style>
|
|
|
|
|
am using windows XP as a development enviroment my web site is published usig IIS
i have 3 pages
Default , Login , Adduser
my authentication is "Forms"
my DB is saved in an XML File existing in the project folder which is c:\inetbub\wwwroot\MyApp
in the login form i check the user name if it is admin and it has the right password i use
"Server.transfer("Adduser.aspx")" to go to the addu user page
the page is displayed well but the main active code in this page targets to edit the xml file
while this code is initiated a windows login form appears again and i gave it all the avaialble users found on my machine but i could not pass it so i cant add or edit any new user.
by the way while my application was file based this problem was not existing
also the anonymous authintication is allowed and windows authentication too
Please some one help me with this error
thnaks
|
|
|
|
|
I have a asp page who return a set of data from sql server 2008 and it work fine on a lot of machines.
But in some one machines the records are returned only partially (with the same query??)
Sam body have an idea on this problem?
|
|
|
|
|
Probably more suitable for the asp.net board.
When you view the source of the rendered html page does is it complete, i.e. does it end with ?
|
|
|
|
|