|
Andy Tek wrote: My goal is to fetch all unique/distinct values in a GridView. In this case, I'm trying to get all unique ProductCode.
Sounds good. So, where is the issue?
You need to use DISTINCT keyword in your query to fetch the record from database.
|
|
|
|
|
I want to let some users download some files from my website and I don't want them to see the physical path of the downloading file.
I moved the files in a folder outside of my web folder and use Response.WriteFile(filePath) to download them. this help me to hide the path but this method doesn't support resume download which I really want it.
So what method you recommend I use?
Thanks
|
|
|
|
|
Dear All,
I have multiple applications(build in asp.net) for them i have a single login page and later on the basis of links given user can launch any application (All web applications). Now i am planning to give any application to the user in which they can login (login once per day and need option to "remember me") i want that application must minimize to taskbar and later on the basis of certain events user must get popup displayed on his desktop or PC. Please help me and suggest me that where to start or what to do ......
ashish sharma
|
|
|
|
|
Sticky problem with a few WCF REST services on a production machine. All the services are fine across other servers, failing any interactions on one particular server with a 400 Error.
We have a couple of REST services contained in our basic webforms application. We're calling these via POST method from javascript (raw js, no jQuery). These services then use a standard service reference to call down to "real" WCF services (not restful). All seems fine on several dev machines and several other live sites, but for one of our sites, all we get out of the REST side of things are 400 (Bad Request) errors. We've tried various things:
Dropped a "Really simple rest" service onto the same server, call in the same way and works fine - so don't think it's a server issue.
Checked IIS config for things like wildcard maps etc - all seems to be the same as other servers.
Written a quick Powershell script to call - this also fails with a 400, so we think our JS side of things is OK.
Checked request format etc (JSON) in Fiddler - seems to be fine and the same as works on other servers.
Tried to create a new instance of our complete app on the same server - same problem, so it looks like it's something specific to our server side code in this app only, except the server side code is the same as the really simple service above - with one exception - we use code to create our binding object and endpoint rather than having them in web.config. The settings we use are however the same as per the standard info added when adding the normal service reference.
We're about running out of ideas on this one, so any pointers as to areas to look at would be greatly appreciated.
C# has already designed away most of the tedium of C++.
|
|
|
|
|
How to open twiiter login page using rest api v1.1 twitter
in asp.net
|
|
|
|
|
|
Hey, can anybody help me with this? I have the following code, I put the pop-up related part into an empty webform and that works fine, but in the form that I really want to have that, it doesn't work! there is no error showing what is wrong with this! (the script manager is on the master page). Any note or comments to help me to figure out what is wrong with it?!
here is the code:
/*for user code pop-up */
.confirm-dialog .base
{
BORDER-TOP: #ddd 1px solid;BACKGROUND: url(img/base.png) no-repeat left bottom;
PADDING-BOTTOM: 4px;MARGIN-LEFT: -11px;MARGIN-RIGHT: -11px;
PADDING-TOP: 4px;TEXT-ALIGN: center;
}
.modalBackground
{
background-color:Gray;filter:alpha(opacity=70);opacity:0.7;
}
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content2" ContentPlaceHolderID="headerContent" runat="server">
<script type="text/javascript">
function Popup()
{
var modalPopupBehavior = $find('ModalPopupBehavior1');
modalPopupBehavior.show();
}
</script>
<style type="text/css">
.confirm-dialog
{
margin-bottom: 0px;
}
</style>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="phBody" runat="server">
<div class="PageDesc">
<asp:Localize ID="userCodesPageDescr" runat="server" EnableViewState="False"
meta:resourcekey="userCodesPageDescrResource1" Text="User Codes enable individual users to arm and
disarm your security system. Check 'Security Panel Access' to give a user local access so they can arm/disarm
through the system keypad. Uncheck it to remove local access temporarily - the code will still show
on the website. (Note that user codes must be 4 digits. Codes 0000 and 0001 are not allowed.)"></asp:Localize>
</div>
<div class="PageDesc" align="right">
<asp:LinkButton ID="lbtnRequestUserCode" runat="server" OnClientClick="Popup()"
meta:resourcekey="lbtnRequestUserCodeResource1"
CausesValidation="False">Request Panel User Codes</asp:LinkButton>
</div>
<div>
<asp:Panel ID="confirmPanel" runat="server" BackColor="White" Width="325px" CssClass="confirm-dialog"
meta:resourcekey="confirmPanelResource1">
<div style="background-color: #EEEEEE; font-weight: bold; padding: 5px 5px 5px 5px;">
<asp:Localize ID="Localize1" runat="server"
meta:resourceKey="locConfirmDeleteRc1" Text="Request User Codes from Panel"></asp:Localize></div><br />
<div style="padding: 0px 10px 15px 10px;">
<asp:Localize ID="Localize2" runat="server"
meta:resourceKey="ConfirmDeleteTextRc1"
Text="Are you sure you would like to replace the website user codes with the user codes from the panel?"></asp:Localize> <br /><br />
<asp:Localize ID="Localize3" runat="server"
meta:resourceKey="ConfirmDeleteTextRc1"
Text="<b>Note: Codes uploaded from the panel will overwrite those in the website if they are out of sync.</b> "></asp:Localize> <br /><br />
<br /><br />
<table width="100%">
<tr>
<td style="text-align: center;">
<asp:Button ID="butConfirmYes" runat="server" Text="Countinue" CssClass="styledbutton"
meta:resourcekey="butCountinue_userCode1" OnClientClick="Popup();"/>
</td>
<td> </td>
<td style="text-align: center;">
<asp:Button ID="butCancel" runat="server" Text=" Cancel " CssClass="styledbutton" meta:resourcekey="butCancel_userCode" />
</td>
</tr>
</table>
</div>
</asp:Panel>
<asp:Panel ID="pnlModal" runat="server">
<ajax:ModalPopupExtender ID="modalPopup" runat="server" BehaviorID="ModalPopupBehavior1"
CancelControlID="butConfirmNo" OkControlID="butConfirmYes"
PopupControlID="confirmPanel" TargetControlID="lbtnRequestUserCode"
DynamicServicePath="" Enabled="True" BackgroundCssClass="modalBackground" />
</asp:Panel>
</div>
<uc1:UserCodesControl ID="usercodes" runat="server" />
<asp:Panel ID="pnlCSNote" runat="server" Visible="False" CssClass="PageDesc"
style="margin-top: 10px" meta:resourcekey="pnlCSNoteResource1">
<p><span style="font-weight: bold">
<asp:Localize ID="labelNote" runat="server" EnableViewState="False"
meta:resourcekey="labelNoteResource1" Text="Note:"></asp:Localize>
</span>
<asp:Localize ID="userCodesNote" runat="server" EnableViewState="False"
meta:resourcekey="userCodesNoteResource1" Text="The changes you make on this page will not update the response information
in the central monitoring station. In order to make changes to the response information
stored at the central station, which is used to respond to alarm signals from your
account, you should contact your alarm dealer or the central station directly."></asp:Localize>
</p>
</asp:Panel>
</asp:Content>
|
|
|
|
|
Take out "CancelControlID" property and it should work.
There are no button with the ID "butConfirmNo"
|
|
|
|
|
Thank, it works!
but now I have the problem with button
butConfirmYes , since its onclick event doesn't fire! can anyone help me with this?!
<asp:Button ID="butConfirmYes" runat="server" Text="Countinue" CssClass="styledbutton"
meta:resourcekey="butCountinue_userCode1"
onclick="butConfirmYes_Click1" CausesValidation="False"/
>
and in cs file I have
protected void butConfirmYes_Click1(object sender, EventArgs e)
{
context.SelectedCustomer.Unit.Panel.RequestUserCodes();
ErrorManager.AddMessage((string)GetLocalResourceObject("Error_CommandSent"));
}
|
|
|
|
|
I fixed that, thanks.
I should delete the
OkControlID="butConfirmYes"
|
|
|
|
|
I have one form that is built in asp.net containing fields such as name, bank deatils etc.
after filling that online form the user will submit the data and on clicking a button pdf of the whole form filled by the user must be generated.
how can i do this using itext sharp?
also mention another any open source third party tool for this job if available and better than itextsharp??
plz reply ASAP.
|
|
|
|
|
|
k.
can u tell me how can we set the background color of the text written in paragraph
as
Paragraph heading=new paragraph("know your client");
doc.add(heading);
I want to color or highlight the text "know your client"
plz reply
|
|
|
|
|
Know your client
above is demonstration.
<p style="background-color:green;">Know your client</p>
--AP
|
|
|
|
|
k.
Thanks for your continuous replies......
I have written the following code for highlight the text in pdf using itextsharp in asp.net
Know your client ;
but i am getting the error in opening and closing tag of and
the error is expected ;
and also the text know your client error is doesnot exist in current context.
plz reply as soon as possible.
|
|
|
|
|
|
still getting error.
actually i am using asp.net on the click event of a button the pdf will be generated so in code i make a function which will generate a pdf.
errors after placing the code in ""
are:
only assignment,call,increment,decrement and new object expressions can be used as a statement
the name background does not exist in current context.
and many more.
|
|
|
|
|
one more thing i would like to ask.
the pdf generated using itextsharp will be generated to the client when he/she will completed the form filling process then on clicking the generate pdf button the pdf will be generated regarding the details which are fi;;ed by the client.
now i would like to ask is there any need of licence etc to use for itextsharp commericially purpose.
THANKS IN ADVANCE.
plz reply ASAP.
|
|
|
|
|
Member 9798541 wrote: now i would like to ask <layer>is there any need of licence etc to use for itextsharp commericially purpose.
Not a lawyer
but for your Knowledge,Infomation is as below:
iText(iText#)[^] is a free and open source library for creating and manipulating PDF files in C#.version 5.0.0 (released Dec 7, 2009) it is distributed under the Affero General Public License[AGPL] v3.
"Projects that do not want to provide their source code may either purchase a commercial license to iText 5 for an undisclosed price or continue using previous versions of iText under the more liberal license without any changes" that means for using iText v5.0 you have to buy a lisence.However Versions of iText through 4.1.6/4.2.0 were released under the MPL[^] and LGPL[^] licenses, which allowed them to be used in closed-source software projects. check more detail[^]
see terms of use[^]
website for itext[^]
They(itext) pay me from time to time to provide email support.
----
vote if it helps you.
-----
Abhishek Pant
|
|
|
|
|
Member 9798541 wrote: how can i do this using itext sharp?
You should have tried something before posting it. Start from here: Convert text into PDF using ASP.NET and C#[^]. There are more articles on using iTextSharp here on CP itself, just search for it.
Member 9798541 wrote: also mention another any open source third party tool for this job if available and better than itextsharp?
Not that I am aware of.
|
|
|
|
|
aspx
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="UserID" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="UserID" HeaderText="UserID" ReadOnly="True"
SortExpression="UserID" />
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="Image2" runat="server" ImageUrl='<%# "Handler.ashx?UserID="+ Eval("UserID") %>' Height="150px" Width="150px"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
_____________________________________________________________________________________________________________________________________________________________
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [UserID], [Image] FROM [Users] WHERE ([UserID] = @UserID)">
<SelectParameters>
<asp:CookieParameter CookieName="userid" DefaultValue="" Name="UserID"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
_____________________________________________________________________________________________________________________________________________________________
public class Handler : IHttpHandler
{
string strcon = ConfigurationManager.AppSettings["ConnectionString"].ToString();
public void ProcessRequest(HttpContext context)
{
string imageid = context.Request.QueryString["UserID"];
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
connection.Open();
SqlCommand command = new SqlCommand("select UserID,Image FROM Users where UserID=" + imageid, connection);
SqlDataReader dr = command.ExecuteReader();
dr.Read();
// context.Response.BinaryWrite((Byte[])dr[0]);
context.Response.BinaryWrite((Byte[])dr[dr.GetOrdinal("Image")]);
connection.Close();
context.Response.End();
}
public bool IsReusable
{ ........................ with close properly
_____________________________________________________________________________________________________________________________________________________________
Database
UserID,UserName,Name,Image (UEC80001,Michael,MyName,<Binary data>)(nvarchar(50),nvarchar(50),nvarchar(50),image)
_____________________________________________________________________________________________________________________________________________________________
|
|
|
|
|
Apart from the fact that you're not setting the ContentType[^] of the response, you have a SQL injection vulnerability[^] in your code:
string imageid = context.Request.QueryString["UserID"];
...
new SqlCommand("select UserID,Image FROM Users where UserID=" + imageid, connection);
Anyone with access to your site could call Handler.ashx?UserID=1;DELETE FROM Users; , and your code would happily execute two queries: one to select the image for UserID 1, and one to delete all records from the Users table.
Change your code to use a parameterized query:
public sealed class Handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string imageid = context.Request.QueryString["UserID"];
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[dr.GetOrdinal("Image")]);
}
}
}
public bool IsReusable
{
get { return true; }
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
appreciate Richard reply~
<asp:sqldatasource id="SqlDataSource1" runat="server"
="" connectionstring="<%$ ConnectionStrings:ConnectionString %>" selectcommand="SELECT [UserID], [Image] FROM [Users] WHERE ([UserID] = @UserID)">
<SelectParameters>
<asp:cookieparameter cookiename="userid" defaultvalue="" name="UserID"
="" type="String">
</SelectParameters>
i using the cookie to show the particular user image,so at my side should how to call?
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%#"Handler.ashx?UserID=1;"+Eval("UserID")%>' Height="150px" Width="150px"/>
</ItemTemplate>
</asp:TemplateField>
ImageUrl='<%#"Handler.ashx?UserID=1;"+Eval("UserID") can i calling by using cookie? at handler cant request cookie @@ other that this handler have other method to display image?
|
|
|
|
|
If you want to use a cookie instead of a query-string value, change your Image to:
<Image ID="Image1" runat="server" ImageUrl="Handler.ashx" Height="150px" Width="150px"/>
and change the start of the ProcessRequest method to:
var cookie = context.Request.Cookies["userid"];
if (null == cookie) throw new HttpException(404, "Cookie not found.");
string imageid = cookie.Value;
NB: You'll still need to use a parameterized command to avoid SQL injection. Cookie values can be altered by the user almost as easily as query-string values.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
ok thx i try ^^
|
|
|
|