|
sorry for keep on disturb u and thank u very much
By using ImageUrl="Handler.ashx", can show the data on gridview?
i'm first time using handler XD. for me i set the following code at web.config izit correct?
why it will not previous any error message on browser when my handler code got problem.
<system.web>
<httpHandlers>
<add verb="*" path="Handler.ashx" type="ShowImage,System.Web.UI.SimpleHandlerFactory" validate="true" />
</httpHandlers>
<urlMappings enabled="true">
<add url="~/MyProfile.aspx" mappedUrl="~/Handler.ashx"/>
</urlMappings>
</system.web>
The code should be no problem why still cant function, my connection correct ?
public void ProcessRequest(HttpContext context)
{
var cookie = context.Request.Cookies["userid"].Values.ToString();
if (null == cookie) throw new HttpException(404, "Cookie not found.");
string imageid = cookie;
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
using (SqlConnection connection = new SqlConnection(connectionString))
using (SqlCommand command = new SqlCommand("SELECT UserID, Image FROM Users WHERE UserID = @userID", connection))
{
command.Parameters.AddWithValue("@userID", imageid);
connection.Open();
using (SqlDataReader dr = command.ExecuteReader(CommandBehavior.CloseConnection))
{
if (!dr.Read()) throw new HttpException(404, "Image not found.");
context.Response.ContentType = "image/jpeg";
context.Response.BinaryWrite((byte[])dr["Image"]);
}
}
}
|
|
|
|
|
The first lines should be:
var cookie = context.Request.Cookies["userid"];
if (null == cookie) throw new HttpException(404, "Cookie not found.");
string imageid = cookie.Value;
If that still doesn't work, try navigating directly to the handler to see what error it produces.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
how to
navigating directly to the handler ?
|
|
|
|
|
In you web browser, go to the address bar and type in the URL of the handler. The exact URL will depend on your setup; if you're not sure, start with the grid page and replace the "PageName.aspx" with "Handler.ashx" (where "PageName" is the name of your page).
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi, I'm Newbie to ASP.Net and looking for a gridview on the page which will allow me to edit the row information on double clicking on the record, but problem is I've a column in that gridview that should display corresponding to that record image. And also I'm unable to display the image. All these data should come from database.And print the data of the gridview. Thank you..
|
|
|
|
|
I am attempting to import an Excel Spreadsheet (2010, XLSX) to Gridview, then upload to MS SQL 2012 database. There are 30,000 rows in spread sheet approximately. When I run it locally it works just fine. When I put it live on the server it doesn't work properly.
When it is importing into the Gridview it stops at a particular row every time. The row is around 21,000. If I delete the top 10,000 rows from spreadsheet it still stops at that same row. So in other words it doesn't matter if I try 21,000 rows or 11,000 rows it stops at that same one. That tells me it isn't a size or time limit. If I delete the top 16,000 rows and the bottom 5,000 rows. It does go past that record. This tells me the next record doesn't have bad data.
So we know it isn't a size / time issue. We know it isn't corrupt data in the next row. We know the code runs fine locally, but not on server.
I have tried this using datasets and datatables and the results are the same.
Connection String:
string myPath1 = @""+Server.MapPath(".") + @"\"+TextBox3.Text;
string strConn = @"provider=microsoft.ace.oledb.12.0;extended properties=""excel 12.0;HDR=YES"";data source="+myPath1+"";
In web.config I have:
<httpRuntime maxRequestLength="72604736"/>
and
<requestLimits maxAllowedContentLength="72604736" />
GridView code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True" >
</asp:GridView>
Code behind to fill GridView (DataTable)
OleDbConnection myExcelConn = new OleDbConnection(strConn);
OleDbCommand myExcellComm = new OleDbCommand();
OleDbDataAdapter oda = new OleDbDataAdapter();
DataTable myDT = new DataTable();
myExcellComm.Connection = myExcelConn;
myExcelConn.Open();
myExcellComm.CommandText = query;
oda.SelectCommand = myExcellComm;
oda.Fill(myDT);
myExcelConn.Close();
GridView1.DataSource = myDT;
GridView1.DataBind();
Code behind to fill GridView (DataSet) DataSet excelDataSet = new DataSet(); OleDbDataAdapter da = new OleDbDataAdapter(query, strConn);
da.Fill(excelDataSet);
GridView1.DataSource = excelDataSet;
GridView1.DataBind();
Again doesn't matter if I use DataTable or DataSet it produces the same thing.
I have verified the spreadsheet that gets uploaded does contain all the data. I have tried using FTP instead of file upload and same results. I have downloaded the uploaded excel file and ran it locally and again it works just fine.
Using Visual Web Developer Express 2010 with all Service Packs and Updates in C# local machine - Vista Ultimate with all updates Web server - VPS Windows Server 2012 with all updates and MS SQL 2012 with all updates.
Does anyone have any idea and where I should look next to solve the problem?
|
|
|
|
|
I got it working.
Turns out you need to have IMEX=1 at the end of the connection string.
The complete working connection string will look like:
string strConn = @"provider=microsoft.ace.oledb.12.0;extended properties=""excel 12.0;HDR=YES;IMEX=1;"";data source="+myPath1+"";
|
|
|
|
|
Hi,
I have a website mydomain.com and I have few pages under this domains requires authentication which are the member's area pages but NOT all pages under this domains needs authentication.
I added the following to web.config:
<authentication mode="None">
<forms loginUrl="~/Signin" timeout="2880" />
</authentication>
then in the signin page, i added this:
FormsAuthentication.Authenticate(txtEmailAddress.Text.Trim(), txtPassword.Text);
and the following in the pages where I need it to be authenticated:
if (!HttpContext.Current.User.Identity.IsAuthenticated) FormsAuthentication.RedirectToLoginPage();
when I sign it should go to the home.aspx page where I placed the IsAutehnicated but it's going back to the sign page? why is this?
Regards,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
This is not the direct answer to this question but looking at this article and the attached source code, I think your problem will be fixed:
Understanding and Implementing ASP.NET Custom Forms Authentication[^]
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore, Dream. Discover.
|
|
|
|
|
I have a local database to check authentication. You may create same database by C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe.
Create any MVC4 application and look _LoginPartial.cshtml file. You will see line @Html.ActionLink"Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })1. Set your break point at method “Login” in Account controller.
2. Click in login and you will get exception at Unhandled exception at line 115, column 5 in http://localhost:61841/Scripts/jquery.unobtrusive-ajax.js.
But why it is so? How can I use my local database for authentication?
Why the exception is in javaScript?
Do you an idea how to implement Authentication with local database?
Any help will be appreciated.
Agha Khan
|
|
|
|
|
I have implemented the Autocomplete extender in Gridview. My Grid has vertical and horizontal scroll bars. Everything is working fine except when i try to use autocomplete control on the last (3 to 5 ) rows of the grid. It displays the suggestion list but it hides the list behind the horizontal scrollbar of the gid.
Any Suggestions?
|
|
|
|
|
Just a theory
Sounds like the autocomplete is trapped inside the bounderies of the gridview.
You may have to play with css overflow for the gridview, or if the gridview is inside div tags, play with it there.
Something is trapping or moving the autocomplete.
|
|
|
|
|
Message Removed
modified 29-Jan-13 12:48pm.
|
|
|
|
|
Hi,
In my application, i have a webservice, where i am doing some update operation.
I have a scenario here, like i want to display an message box to the user, based on the user input in messagebox(yes/no) i have to perform some operation in the webservice.
FYI : I tried MessageBox.Show() , it will work fine during debugging, if i deploy the same code on the server, MessageBox wont be displayed.
And i am calling this webservice from .aspx file using jquery.
sample code :
[WebMethod]
public string Save(BusinessException exception, BusinessException oldexception)
{
UserContext userContext = GetCurrentUserDataContext();
IList<string> lineExtIds = exception.LineExtIds;
IList<string> ListExtIds = exception.ListExtId;
string username = null;
{
Presenter.Save(lineExtIds,userContext.Login,userContext.Profile);
}
{
return;
}
return "succeed";
}
Could any one tell me how to display an alert message box in this scenario, where the code should be written inside asp.net webservice file.?
|
|
|
|
|
Rocky23 wrote: i want to display an message box to the user, based on the user input in messagebox(yes/no) i have to perform some operation in the webservice.
Show/Ask for yes-no confirmation on UI side before making the Webservice call. Post which, take action. It's a web application where you have client-server model and thus you cannot raise a confirm to client in between server method implementation.
Modify your implementation to handle the confirm before invoking service.
|
|
|
|
|
Sir;
you may be interested with a control like Message Box Control[^]
Help people,so poeple can help you.
|
|
|
|
|
Hi Ali,
Thank you for your suggestion.
But,I can't use MessageBox here, because it is a ASP.NET application.
If i use MessageBox in asp.net, this MessageBox will appear only in debugging mode, but it will not appear once the code is deployed in server.
And i can't even use alert() or confirm() directly, because i have to do this change inside ASP.NET webservice file.
Appreciate any more suggestion/help from your side..
|
|
|
|
|
First the control I suggested is for web applications it is similar to jquery dialog.
Second in web applications you should confirm user request before making the request,
but if the job generated another decision in the server side -like coping example in my article- you should send back a response asking the user for making the decision and make another request complete the job.
Lastly the message box you see on debugging mode is displayed on the server interface and wont be sent to the client.
or use this javascript code.
if (confirm('Are you sure?')){
}
Help people,so poeple can help you.
|
|
|
|
|
JQuery has a message box for web applications that can handle a yes no dialog, but the previous posts are correct, such as using confirm(); on the client side;
|
|
|
|
|
Hello,
In my web application i want to change the color of menu font dynamically.
I am using external css for menu that id is #buttons
the menu font color resides in #buttons a{color:red;}
I want to change it through javaScript dynamically.I have created a session(control value assigned to session) and session value is assigned to hiddenfield.
I have used following code but it's not working proper.
function SetValue()
{
menufontcolor = document.getElementById('buttons');
menufontcolor.style.color =
document.getElementById('HiddenField8').value;
}
I have called SetValue() at body section OnLoad Event.
Please help me..
Thanks
Regards
Sunil Sharma
modified 28-Jan-13 6:32am.
|
|
|
|
|
1. SetValue() & setValue() are two different method names. See it this is the issue.
2. Why hidden field and all? Just switch the css at runtime.
Debug and share what is happening and if you get any error.
|
|
|
|
|
capture the signature from signature pad in Web App.I am using TOPAZ syStems INC Pad Model T-LBK462-KAHSB-R
|
|
|
|
|
Based on the little information shared and not a good framed question, for now all I can share is, probably you can achieve it using ActiveX, but that will be IE only. You have to look into it.
Further, there are paid products for the same, not sure if anything free. Example: http://www.websignaturecapture.com/[^]
|
|
|
|
|
Here is a question[^] for the same.
The OP posts the comment of question as a answer and then Accepts it.
Lunch Time,Check the bad solution.and distribute prizes to good solutions.
|
|
|
|
|
Anyone know about login object in asp.net?
Plz tell me
Nature is Simple but Conceptual
|
|
|
|