|
solo_gaurav wrote: cmd = new SqlCommand("select * from salescounts where ='"+DropDownList1.Text+"'", con);
As the other poster had mentioned, this opens you up for a potential SQL Injection attack. I recommend reading SQL Injection Attacks and Some Tips on How to Prevent Them[^] by Colin Mackay on this site.
If you could shed some light on what are actual data values of DropDownList1.Text would be helpful. Your trouble might be what is being generated as the SQL string and causing it not to bind the data.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
my system did not contain machine.config is not there in the bellow path. How to create machine.config in my system ?.is it mandatory to run asp.net
project or not.
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322(gacutil.exe and regsvcs.exe) are there in that location.
|
|
|
|
|
Ramesh Reddy11111 wrote: my system did not contain machine.config is not there in the bellow path
It is never supposed to be there in the path you mentioned but should be present at the location below:
C:\Windows\Microsoft.NET\Framework\v1.1.4322\CONFIG
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I have a wizard control in my form. In one of the steps there is a file upload control. If the user uploads a file using the browse button and then he clicks on Next button instead of Upload button, the textbox gets cleared.
Is there anyway to retain the string entered in fileupload control textbox so that the user need not enter again? Please help.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
only way is to place the upload file code in the next button as well, check if file is there and if so then upload it while the user is clicking on Next button
|
|
|
|
|
Thanks for the reply. But again, i have to either repeat the code or write the code in a function and call it, which I think is redundancy of code. So what I am thinking is, I can save the file name in the viewstate while uploading. So if viewstate is null, then I can disable the nextbutton else enable it.
So while loading the tab itself, it is disabled since there is no filename in viewstate. So the user has to upload the file.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
I am not a very fond of using ViewState, as it is transferred through the request/response body all the time, hence increasing the size of the data transferred.
Anyways, nice to hear that you got the solution.
|
|
|
|
|
Hi,
Although I have writing C# applications for several years, I only recently launched my first ASP.Net website. The site is run by an internal database in the App_Date folder. The Login page defines a group of Session variables that are retrieved, as needed, from concurrent pages. The Login page works perfectly and loads the Session information to the next page> That page, for security purposes, requires that an additional Password (called Signature) is submitted before it is allowed to advance. The problem is: the next page fails to load because the Session variables needed to load the next page have been nulled, as reported by the following error page:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 456:
Line 457: //Get Session Variables
Line 458: FName = Session["FName"].ToString(); /////This line is highlighted. Changing the order of the variables always reproduces the error on the same line number of the code (458)./////
Line 459: userName = Session["Name"].ToString();
Line 460: site = Session["Site"].ToString();
Source File: \\frigga\home\users\web\b157\\QueryLogger\Alerts.aspx.cs Line: 458
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Alerts.Page_Load(Object sender, EventArgs e) in \\frigga\home\users\web\b157\hy.softdynamics\QueryLogger\Alerts.aspx.cs:458
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
Now, I am sure that the first page pass is working correctly because some of the data displayed on that page is the result of Session value queries to the database. That leaves the following question: What would cause the Session values to be nulled when passing from the second to the third page? .... and could this the result of improper >Net framework on the hosting server? Or perhaps anything else? Any help would be greatly appreciated.
Pat
|
|
|
|
|
Pat,
Where did you stored data in the Session? Your application is running from VS or IIS ? What is the session mode ?
Always check session null before read the value from it.
if(Session["FName"] !=null)
FName = Session["FName"].ToString();
|
|
|
|
|
Yes, thank you for pointing that out Abhijit. I will make that change immediately (I was in too much of a hurry.. ). But the problem is still there. The server is hosted by a hosting service (Hypermart), so I am not sure about the server, but I think it is IIS. I'll try to find out and let you know....Pat
|
|
|
|
|
I think you are trying to retrieve the Session variable after clearing out it.
Check like this
if(Session["Variable"] == null)
{
}
else
{
}
|
|
|
|
|
Just guessing, but this [^]could be a reason.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi,
I am using the following code to retrieve the file name of a pdf document stored in a database. Once I have the string, I have the PDF's stored in a folder under App_Data. I need it to load on the clients computer using their internal PDF reader (whatever that might be....usually Adobe Reader). I know that all I need to do is to point to the Pdf for it to open on the client side, but since it is different each time depending on the line that was selected from the grid, how do I pass the value? Or is there a better way to do this?
CS Code
//Define the row and cell
int theRow = Convert.ToInt32(e.CommandArgument);
int theCell = 6;
//Get the Row information
GridViewRow gvr = GridViewResults.Rows[theRow];
//Get the information from the cell
this.thePdf = gvr.Cells[theCell].Text;
//Call Clients PDF reader via a Hyperlink ?? OR ??
ASPX Code
<%--Gridview--%>
<asp:GridView ID="GridViewResults" runat="server" CssClass="gridViewSpecs"
HeaderStyle-Height="30px" Height="100px" Width="770px" BackColor="White"
RowStyle-Height="25px" EnableViewState="true"
onrowcommand="GridViewResults_RowCommand"
onselectedindexchanged="GridViewResults_SelectedIndexChanged" >
<RowStyle Height="25px" />
<HeaderStyle Height="30px"></HeaderStyle>
<HeaderStyle BackColor="#CCCCCC" />
<Columns >
<asp:CommandField HeaderImageUrl="~/Graphics/adobe2.PNG" ShowSelectButton="True" />
</Columns>
</asp:GridView>
Thank You, Pat
|
|
|
|
|
Just give simple hyperlink of that PDF for download, which allows the End user either Sava or Open the Pdf.
You can also have a look into this article Downloading Files
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
OK Abhijit,
Sorry about the delayed response. I had to leave for a bit.
Thank you for the insight, but as I said in the post, it is not a hard coded link. There are over 1500 pdf's that can be called, depending on the results of the search. How do I pass the variable for the correct one in the form of a link so it can be accessed and clicked on by the Client? If you can, please supply a code sample that I can work from that will coordinate with the actual code that I supplied in the original request.
Thank You
Regards, Pat
|
|
|
|
|
From your first post.
PDTUM wrote: //Get the information from the cell
this.thePdf = gvr.Cells[theCell].Text;
Does it contain the actual pdf file path ?
You need to bind the pdf path at runtime only.
|
|
|
|
|
Hello Abhijit,
The path is not part of the returned string. The permanenet path to all the pdf's will always be
(App_Data/Pdfs/pdf001.pdf) WHERE pdf001.pdf is the name of the selected pdf. The returned string value will always look like (pdf001.pdf).
So....I need to know how to pass this to a link in code. In C#, I do it like this:
System.Diagnostics.Process.Start(Application.StartupPath + @"\PDFs\" + pdf);
Obviously, this will not work in ASP.net. All that should be necessary is to be able to create a link when the grid link is clicked on that uses the value of the pdf string variable as returned from the GridView so that when the line is selected from the GridView, it automatically creates the link and deploys it so that the client's PDF reader will launch and load the pdf. However, I do not know how to accomplish this.
If there another or better way, do let me know and supply me an example using the code sample that I submitted as a starting point....Thank You
Best Regards, Pat
|
|
|
|
|
Don't Store PDF in APP_DATA . Creates another folder like Files\Pdf under root directory and store the PDF over there.
Because
App_Data Folder used as a "data storage " for the web application. It can store, .mdf, .mdb, XML, etc files. It can be accessible from any where of your web application. The real advantage is that any file you place in App_Data won't be downloadable.
Hope you got my point.
Here is one of my complete Article on ASP.NET Application Folder. You may look into it.
ASP.NET Application Folder
|
|
|
|
|
Thank You Abhijit,
Actually, that is exactly what I did. I am sorry I was not clear about it, but I did not define it in detail since that is not the problem I was asking about. The path to the files is /App_Data/PDFs/file001.pdf. Thank you for the tip. Now, if I could get an answer to the original problem of how to create a hyperlink that will accept a variable depending on the line that was selected, I could finish this application. Any help you could give there would be appreciated. Best Regards, Pat
|
|
|
|
|
I have one quick suggestion to implement it, You can store only the file path in the Table (Store File in Physical Location) . And bind with the Grid view Hyperlink Field.
Here is an good Example, Hope this will help you
how to download files from a gridview?
|
|
|
|
|
Abhijit,
Thank you for your help.....and all others that responded to my request. Your help is greatly appreciated. I have come up with a solution for this dilemma, as submitted to me by PeteNet at the ASP.Net forum. It is nice and tight, easy to understand, and works perfectly. I wish to post it here for the benefit of all others that might be interested.
use a LinkButton within a TemplateField in your GridView:
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandArgument = '<%#Eval("<filename>")%>' OnClick="OpenPDF">OpenPDF</asp:LinkButton>
</ItemTemplate>
in the codebehind write the event handler OpenPDF:
protected void OpenPDF(object sender, EventArgs e)
{
LinkButton lnk = (LinkButton)sender;
if (lnk != null)
{
Response.AddHeader("content-disposition", "attachment; filename=" + lnk.CommandArgument + ".pdf");
Response.WriteFile(Server.MapPath("~/PDFs/" + lnk.CommandArgument.ToString() + ".pdf" ));
Response.End();
}
}
commandArgument will hold the filename (from the database, for the current row in the grid)...depending on whether you have the extension stored along with the filename you may want to append or remove ".pdf" in the code (lnk.CommandArgument + ".pdf")
replace <filename> with the actual value of your database column name that holds the file name
if you use VB.NET you can convert over here: http://www.developerfusion.com/tools/convert/csharp-to-vb/
Good Luck and Best Regards to All, Pat
|
|
|
|
|
|
Error It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.
This error can be caused by a virtual directory not being configured as an application in IIS.
C:\Inetpub\wwwroot\sample10\XmlDataSource\web.config 46
ramesh reddy
ramesh.sanikommu@gmail.com
|
|
|
|
|
Do you have multiple web.config in the application?
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Ramesh Reddy11111 wrote: This error can be caused by a virtual directory not being configured as an application in IIS.
This is indeed a beautiful example of error handling where it is clearly saying that what the problem is.
You have a directory in your application which contains another web.config. You should convert this directory into application. Use the Convert to Application option from the IIS menu.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|