|
Actually, my requirement is to download file from server to client machine without open file open, save dialog box (in silent mode).
i donot want to use ActiveXObject("ADODB.Stream") to save file client side,
and code below always show file open, save dialog box;
Response.AppendHeader("content-disposition", "inline; filename=" + strFileName);
Response.ContentType = ("application/octet-stream");
Response.BinaryWrite(byteRead);
but am really looking for silent file downlon from server to client either using web server calling from client side or something else for solution.
or
Is it possible to write " Response.WriteFile(path); " from Javascript to avoid file open, save dialog box??
thanks in advance.
|
|
|
|
|
kbsnet wrote: really looking for silent file downlon from server to client
Not possible. A client always has to accept a file to download - otherwise its known as a virus.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hi all,
I have some following code:
DataTable dt = m_Data.GetInfo();
GridView1.DataSource = dt;
GridView1.DataBind();
Table dt, in fact, has 5 columns A, B, C, D, E, but I want to display just 3 columns in datagridviews A, B, C with new names A1, B1, C1. And I do not know how to do.
Have you got any suggestion for me!
Thank kiu so much!
|
|
|
|
|
Hi
When designing the page page itself you can do that.
Set the column visibility property to false.
And which all columns you want to display set the name in header of ItemTemplate. Working with Item templates, you can customise however you want
Naina
Naina
|
|
|
|
|
You can use BoundField in your gridview. Also make sure to set AutoGenerateColumns to false for your gridview.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
I sure that to do as you said I must choose a datasource & configure it when designing page, but I can not do that because my datasoucre is unknown until application runs. It is got by the following code:
public DataTable GetInfo()
{
DataTable dt = new DataTable();
try
{
SqlCommand cmd = new SqlCommand("sp_GetInfo", m_sqlConn);
cmd.CommandType = CommandType.StoredProcedure;
if(m_sqlConn.State == ConnectionState.Closed)
m_sqlConn.Open();
dt.Load(cmd.ExecuteReader(CommandBehavior.CloseConnection));
}
catch (Exception ex)
{
throw ex;
}
return dt;
}
.........
DataTable dt = m_Data.GetInfo();
GridView1.DataSource = dt;
GridView1.DataBind();
...................
|
|
|
|
|
This Can Be Done in two ways
1)Selecting only the required columns..!
2)Using the following code in
DataTable dt = m_Data.GetInfo();
GridView1.DataSource = dt;
GridView1.DataBind();
if (GridView1.Columns.Count > 0)
GridView1.Columns[0].Visible = false;
else
{
GridView1.HeaderRow.Cells[0].Visible = false;
foreach (GridViewRow gvr in GridView1.Rows)
{
gvr.Cells[0].Visible = false;
}
}
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
modified on Monday, November 30, 2009 12:56 AM
|
|
|
|
|
It worked, but how to change the header name of column A to A1 when displaying?
I have need to change name such as in original table I have a column named "AccInfo", then I must display it with the name "Account Infomation" ...
Your suggestion is highly apprecited!
|
|
|
|
|
Try this code..!
GridView1.HeaderRow.Cells[1].Text = "Account Information";
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
But you will be knowing the columns what all you are getitng from database. If you want to do the same in run time you can do that in RowDataBound().
Regards
Naina
Naina
|
|
|
|
|
Hi All
I want to place the combobox inside the datagridview and value for the combobox should come from database.
please help me with this...searched but could not find
Thanks in advance.
|
|
|
|
|
This is ASP.Net forum.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Hi Venkat ,
try this article..!
http://www.xmlfox.com/datagrid_datagridview.htm[^]
But From Next Time Make Sure You posted your Question In the Right forum..
To Get more help
All the best..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
modified on Monday, November 30, 2009 12:57 AM
|
|
|
|
|
That article is for datagrid. OP is asking for DataGridView.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
I am having trouble getting my ASP search query string to
look up a field Subcategory and display a list
of matches by first character match.
so when an 'A' is entered as the search character, matches
starting with A only are displayed. The script works
for a total list , but however I modify the where/Like line
to put in the last line , the formatting falls apart,
any help much appreciated.
Thanks Bev
strSQL = "SELECT SubCategory, COUNT(*) AS myCount "_
& "FROM Products " _
& "WHERE SubCategory LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "GROUP BY Subcategory " _
& "Order BY Subcategory ;"
(SubCategory LIKE @SubCategory + '%')
|
|
|
|
|
Bev Robins wrote: WHERE SubCategory LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
This will look in any part of subcategory. To get results that starts with search criteria, put the search criteria first and % at the last.
Best wishes,
Navaneeth
|
|
|
|
|
Yes , I know that the search criteria needs to be first,
but I am having difficulty trying to do the correct formatting.
& "WHERE SubCategory LIKE '(% + @SubCategory)" & Replace(strSearch, "'", "''") & "%' " _
Thank you ,
Bev.
|
|
|
|
|
I don't think you need the double quotes logic. You are already building the string like this, '%mysearchstuff%'. Take out the Replace function call.
The problem you may have is if the user enters single or double quotes in the search criteria, then your dynamic SQL would syntactilly fail. Strip single and double quotes out first before building your SQL or use a parameterized query and you won't have to worry about anything.
Cheers,
David
|
|
|
|
|
Hi there
I want to use [Autorize(Roles="admin")] to protect my controller methods but i'm not quite sure how it works. I've set up Form Authentication no problem so without roles it works ok
In my controller I have the following code when thu user logs on but once logged in I want to set the cookie and then only a user with the role 'admin' can access /Test. Can somebody explain where the Roles in [Autorize(Roles="admin")] actually looks for its data? I want it to recognise only 'admin' from currently logged on users but also when they return and get the role data from the cookie. Am I missing something, lacking understanding or just going about it the wrong way?
public ActionResult Authenticate(string username, string password, string rememberMe)
{
var user = userRepository.GetUserByName(username);
if (user != null && user.password.Trim() == password)
{
SetAuthenticationCookie(username);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
username,
DateTime.Now,
DateTime.Now.AddMinutes(50),
true,
roles,
FormsAuthentication.FormsCookiePath);
string hashCookies = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashCookies);
Response.Cookies.Add(cookie);
return RedirectToAction("index", "Home");
}
else
{
return View("Register");
}
}
[Authorize(Roles = "admin")]
public ActionResult Test()
{
return View("chat");
}
I've got this code in my global.asax:
protected void Application_AuthenticateRequest(object sender, EventArgs e){
if (HttpContext.Current.User != null){
if (HttpContext.Current.User.Identity.IsAuthenticated){
if (HttpContext.Current.User.Identity is FormsIdentity){
FormsIdentity identity = (FormsIdentity)
HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = identity.Ticket;
string[] roles = ticket.UserData.Split(',');
HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(identity, roles); }
}
}
}
Thanks very much
|
|
|
|
|
Hi, lets say I have a folder called dogs on my server. Now theres a bunch of different aspx pages in there, and certain users are only allowed to access certain ones(note:each aspx page cannot do its own authentication). Now when someones goes to server/dogs/page3.aspx im going to use url rewriting to send them to my ashx page. The ashx page will then check the logged in users session, see if he has access to the page he tried to see and then output the resulting page.
I have this working fine on a previous project out putting images. But now im worried that outputting it a similair way will "break" the link between the aspx page and its code behind.
So whats the best way to go about this?
Thanks so much
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
Found a solution from a combination of 2 articles.
Heres the code inside ProcessRequest:
string page = "~/Dogs/Page3.aspx";
Page compiledPage = (Page)PageParser.GetCompiledPageInstance(page, context.Server.MapPath(page), context);
compiledPage.ProcessRequest(context);
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
hellow friends
i want to hide only those controle which clikede by user for session only.
this conrole agine disply after session close
friends its urgent....
modified on Saturday, November 28, 2009 6:46 AM
|
|
|
|
|
angle57 wrote: friends its urgent....
This is very rude around here. Answers are given voluntarily and although it may be urgent to you, it isn't to anyone else here.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
you can try this:
protected void Page_Load(object sender, EventArgs e)
{
if (Session["buttonnamevisible"] == "false")
Button1.Visible = false;
else
Button1.Visible = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
Button1.Visible = false;
Session["buttonnamevisible"] = "false";
}
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 21:47pm.
|
|
|
|
|
Thanks a lot, but I did this with session and flag variables.
Aging
Thank you very much for provide good suggestion.
|
|
|
|