|
oops no,
do I do that on the new page? before appending the header?
I'm not sure i understand
|
|
|
|
|
You do that on the new page but don't stream it to the response until after you've added the header!
|
|
|
|
|
'Open filestream from your file
'Set your headers
Response.BinaryWrite(filestream.GetBuffer())
Response.Flush()
Response.Close()
output.Close()
output.Dispose()
|
|
|
|
|
ok, sorry been a while have been out the office,
whats the namespace for output? system..
sorry im a newbie and can't seem to find it
|
|
|
|
|
Apologies, that shouldn't have been output, that should be your filestream object... copy paste error...
|
|
|
|
|
ok that makes sense, whats the syntax for the binary write?
it wants an arguement of byte[] buffer do i ned to put in the max file size in the squares? and do i need buffer at the end?
thank you so much for yourhelp,
its digging me out of lots of c**p!
mark
|
|
|
|
|
OK , worked out the binarywrite bit,
compiled my site which was all fine
then got server error in my app.
'Specified argument was out of the range of valid values.
Paramater name: offset'?
but I can't see that anythings wrong?
my code so far:
FileStream theFile = File.Open(Session["FullFilePath"].ToString(), FileMode.Open);
Response.AppendHeader("content-disposition", "attachment;filename="+Session["FullFilePath"].ToString());
Response.Write(Session["FullFilePath"].ToString());
long filesize = theFile.Length;
byte[] getContent = new byte[filesize];
Response.BinaryWrite(getContent);
Response.Flush();
Response.Close();
theFile.Close();
theFile.Dispose();
any thoughts at all?
|
|
|
|
|
Hello.
I have a problem - and it's probably me not understanding the concept - but I want to programatically disable all controls in my aspx page - if the user watching the page is not authorized to edit the content.
Now this should be an easy task, so I've tried a couple of methods like looping through the page's Controls property and have all textboxes set their Enabled property to false. The following code does not work. I'm using a MasterPage, but I can't think of anything, that makes this a problem.
When I "ask" the MasterPage to print out the "count" for it's controls property it says there is about 5 items in the list. Although the page contains around 10 TextBoxes!
So what am I misunderstanding here?
Anyway here's the code:
foreach (Control c in Page.Controls)
{
switch (c.GetType().ToString())
{
case "System.Web.UI.WebControls.TextBox":
((TextBox)c).Enabled = false;
break;
case "System.Web.UI.WebControls.DropDownList":
((DropDownList)c).Enabled = false;
break;
case "System.Web.UI.WebControls.ImageButton":
((ImageButton)c).Enabled = false;
break;
default:
break;
}
}
I hope someone can help!
Thanks in advance.
Best Regards
Soeren
|
|
|
|
|
The easiest way to do is showing "50% transparency image" with higher z-order.
All you need to do is that you hav to create one gif image with transparency background. (file size should not be too big.) set the position of that image to absolute. and set the width and height of this image to 100%.. finally, set the zorder of image to highest value..(you may check out "LightBox" javascript toolkit.)
hopefully, you got my point.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message. Thank you.
|
|
|
|
|
Hi
I think better way for disabling fields is to write javascript function. I have added sample code below. Hope this helps.
'aspnetForm' - Form name of a web form
Example:
function DisableFields(vAccessRights)
{
//parameter - vAccessRights - to check access rights for particular user..
elm=document.aspnetForm.elements;
for(i=0; i < elm.length ; i++)
{
if(elm[i].type=="checkbox")
{
var chkboxId = elm[i].id;
//add code to enable / disable field
}
else if(elm[i].type=="textbox")
{
var txtboxId = elm[i].id;
//add code to enable / disable field here
}
}
}
- Harini
|
|
|
|
|
I had some what the same problem . Finally I had put the controls in a panel and do something like this
Dim ctrls As Control
For Each ctrls In Me.Panel1.Controls
If TypeOf ctrls Is TextBox Then
Dim tb As TextBox
tb = ctrls
tb.Text = DateTime.Today
tb.Enabled = False
(instead u can manipulate any property here)
End If
Next
|
|
|
|
|
Use PlaceHoldet instead of panel
<l>Thanks and Regards
Sandeep
|
|
|
|
|
All the ansers above have severe flaws. Doing it client side is a VERY bad idea, especially if security if the reason for disabling them in the first place.
Your code is pretty much correct, the problem is that controls can contain other controls so your foreach loop will only disable the top-level ones. You need to put that in a function that recursevly calls itself if the control has children.
Heres one I use:
private void DisableInputs(Control control)
{
foreach (Control c in control.Controls)
{
if (typeof(HtmlControl).IsInstanceOfType(c))
{
((HtmlControl)c).Disabled = true;
}
else if (typeof(WebControl).IsInstanceOfType(c))
{
((WebControl)c).Enabled = false;
}
DisableInputs(c);
}
}
|
|
|
|
|
As a follow-up to what I said about security - even setting the disabled attribute server-side won't stop the user being able to submit changed data, there is always a way (eg Firebug). You'll also want to perform some sort of authenitcation check in whatever code handles the posted data.
|
|
|
|
|
Actually iam developing an ASP.NET application using VB.NET...there how can i create a table with its contents making a link to another page?
|
|
|
|
|
Dynamic Tables or Static?
Regards,
|
|
|
|
|
Why dont you use Datagrid or DataList or repeater?
You can add "Hyperlink" or "Linkbutton" in template columns..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message. Thank you.
|
|
|
|
|
|
Hai to all,
I have a report that I have generated in crystal reportss and calling in my webform.The report displays only when i save the report with the option "savedata with report" in Crystal report.If i deactvate that option it is giving an error like following.If use that savedata with report, the data in the report is old and out of date. What changes i have to make for this???
I am using sqlserever as my backend
The code i have given for this is
On the page load------->
Try
dbconnection()
Dim rpt As ReportDocument = New ReportDocument
CrystalReportViewer1.DisplayGroupTree = False
rpt.Load(Server.MapPath("rptCentre.rpt"))
CrystalReportViewer1.ReportSource = rpt
CrystalReportViewer1.DataBind()
Catch ex As Exception
CrystalReportViewer1.Visible = False
Response.Write(ex.Message)
Finally
con.Close()
End Try
Error is----->
Logon failed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.
Thanks in advance.
Regards,
kissy
kissy
|
|
|
|
|
rptLogOnInfo = New CrystalDecisions.Shared.TableLogOnInfo()
rptLogOnInfo.TableName = "rptCharts"
rptLongonInfo.ConnectionInfo.UserID = UserID
rptLongonInfo.ConnectionInfo.password = password
CrystalReportView1.LogOnInfo.Add(rptLogonInfo)
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
sylvester_g_m@yahoo.com
|
|
|
|
|
Thanks for ur answer Mr.Sylvester.
But i can not understand the above,Bcz i am using the report already generated in crystalreports.
"rptCharts" is the tablename and not report.
I am loading the report in my code(as per my precious message).
If is this only the solution give me correct idea please.
Thanks once againg
Regards,
Kissy
kissy
|
|
|
|
|
Hi,
Can anyone help,
I want that data in datagrid should be placed in single line. Can i somehow
set multiline property of datagrid to false, and i also do not want d width of
COLOUMN to increase if multiline property is set false ,instead can i hve a
TOOLTIP which will show d entire data if a particular row is selected in a
datagrid .
|
|
|
|
|
you can set the tool tip property of the control. by finding that control in the Item databound event and then assisgning that value as the tool tip.
I tried it for a hyperlink, textbox etc , however was not able to get it happwning for a drop down.
Can somebody give an idea as to how to make it happen
|
|
|
|
|
I have a Gridview and a Formview control in a web-page laid out in a master-detail fashion, with paging enabled for both the controls and sorting enabled for some columns in the Gridview. With only paging enabled for both controls, I am able to synchronize the two views, but as soon as sorting is requested, the two views go out of sync. I tried hooking into the sorting and sorted event of the gridview control, to manipulate the formview's sort order, without success.
can anyone help me out?
The test of the puddng is in eating it.
|
|
|
|
|
when i move the mouse on particular cell of the row i should get the content of the cell in some variable in code behind page .
thanks in advanc e
|
|
|
|