|
That code will work but that way of retrieving settings from Web.config is outdated/deprecated and may not work in future versions of .net.
This link is the recommended way of doing it, according to Microsoft:
Microsoft Recommendation
|
|
|
|
|
Hi,
Yes that is absolutely correct, we are in process of converting this 2.0 application into 4.5, so the one that I have put was 2.0 code, but your suggestion definitely helped me. Thank you very much.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
But I don't know why but the namespaces and classes from that assembly are not at all coming in the intellisense. When I put those names explicitly they were giving syntax errors.
Please help me in this regards.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
In code-behind pages, you link a prefix to the assembly, which is done in the code I posted in previous post. After that, you place a control on your webpage. It will have a prefix, then the name of your control, and only the name of that control. Giving the full name will indeed give syntax errors.
If you placed
<%@ Register TagPrefix="vg" NameSpace="coolstuff" Assembly="coolstuff" %> on top of your page, you should place
<vg:CoolControl id="testcontrol" runat="server">
in your page where you place your control(s).
If I'm misinterpreting your question, please provide more details.
|
|
|
|
|
I am using OpenXML to generate Excel doc how to I apply styles for specific cell?
Dim CellStyleFormats As New CellStyleFormats
With CellStyleFormats
.?????
End With
mergeCell.Append(CellStyleFormats)
mergeCells.Append(mergeCell)
|
|
|
|
|
Hi,
I have some aspx pages, as we are adding some new applications which are going to use some of the same pages we want to make those common pages as user controls.
I started making the aspx pages into User controls I changed the name of the files to ascx, ascx.cs, removed page attribute and put the control attribute, removed html, body and form tags from aspx file, in code behind I made change to inherit from UserControl class. Everything looks good upto this.
But those previous aspx pages were accessing some user controls, now those controls are displaying error message. Like at uc1:htmlhead and uc1:formheader it is displaying error message as "Unrecognized tag prefix or device filter uc1".
Below are the register and control directives for the user control. For the current User Control I have taken Control directive and for other ones I have taken Register directive. Am I missing any where. Please help me or suggest me or give me a link, any type of help is very helpful. Thanks in advance.
<%@ Register TagPrefix="uc1" TagName="HtmlHead" Src="../Includes/HtmlHead.ascx" %>
<%@ Page Language="c#" CodeBehind="ChangePass.ascx.cs" AutoEventWireup="false" Inherits="DIS.CnpWeb.Core.ChangePass" %>
<%@ Register TagPrefix="uc1" TagName="FormFooter" Src="../Includes/FormFooter.ascx" %>
<%@ Register TagPrefix="uc1" TagName="FormHeader" Src="../Includes/FormHeader.ascx" %>
<uc1:htmlhead id="HtmlHead1" runat="server"></uc1:htmlhead>
<uc1:formheader id="FormHeader1" runat="server"></uc1:formheader>
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Can you provide the top section of you user control?
|
|
|
|
|
Here is the whole form
<%@ Control Language="c#" CodeBehind="~/Rollover.ascx.cs" ClassName="Rollover" AutoEventWireup="false" Inherits="DIS.CnpWeb.Core.Rollover" %>
<%----%>
<asp:Table ID="tblSection0" runat="server" Width="100%">
<asp:TableRow>
<asp:TableCell ID="tdpSection0" Text="Rollover"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="3">
<asp:Image runat="server" ID="imgSection0"></asp:Image>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Table ID="tblError0" runat="server" Width="100%" CellSpacing="1" GridLines="Both"></asp:Table>
<p></p>
<asp:Table ID="tblError1" runat="server" Width="100%" CellSpacing="1" GridLines="Both"></asp:Table>
<p></p>
<asp:Table ID="tblSection1" runat="server" Width="100%">
<asp:TableRow>
<asp:TableCell ID="tdnSourceYear" Text="(1)" runat="server"></asp:TableCell>
<asp:TableCell ID="tdpSourceYear" Text="Source Year:" runat="server"></asp:TableCell>
<asp:TableCell ID="tddSourceYear" Width="20%" Text="200X" HorizontalAlign="Left" runat="server"></asp:TableCell>
<asp:TableCell ID="tdpDataSource" Width="20%" Text="Data Source:" runat="server"></asp:TableCell>
<asp:TableCell ID="tddDataSource" Width="30%" Text="Some Server" runat="server"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="tdnTargetYear" Text="(2)" runat="server"></asp:TableCell>
<asp:TableCell ID="tdpTargetYear" Text="Target Year:"></asp:TableCell>
<asp:TableCell ID="tddTargetYear" Text="200Y" HorizontalAlign="Left" runat="server"></asp:TableCell>
<asp:TableCell ID="tdpCatalog" Text="Database Name:" runat="server"></asp:TableCell>
<asp:TableCell ID="tddCatalog" Text="MyDatabase" runat="server"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="tdnProgSelect" Text="(3)" runat="server"></asp:TableCell>
<asp:TableCell ID="tdpProgSelect" Text="Programs to Process:"></asp:TableCell>
<asp:TableCell ID="tddProgSelect" ColumnSpan="1" runat="server">
<asp:DropDownList ID="ddlProgSelect" runat="server"></asp:DropDownList>
</asp:TableCell>
<asp:TableCell ID="tddSelectPgm" runat="server" ColumnSpan="2">
<asp:Button ID="btnSelectPgm" runat="server" Text="Select Program"></asp:Button>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tdrNslp" HorizontalAlign="Left" runat="server">
<asp:TableCell ID="tdnNslp" ColumnSpan="2" runat="server"> </asp:TableCell>
<asp:TableCell ID="tddNslp" ColumnSpan="3" runat="server">
<asp:CheckBox ID="chkNslp" Text="NSLP" runat="server"></asp:CheckBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tdrSfsp" HorizontalAlign="Left" runat="server">
<asp:TableCell ID="tdnSfsp" ColumnSpan="2" runat="server"> </asp:TableCell>
<asp:TableCell ID="tddSfsp" ColumnSpan="3" runat="server">
<asp:CheckBox ID="chkSfsp" Text="SFSP" runat="server"></asp:CheckBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tdrCI" HorizontalAlign="Left" runat="server">
<asp:TableCell ID="tdnCI" ColumnSpan="2" runat="server"> </asp:TableCell>
<asp:TableCell ID="tddCI" ColumnSpan="3" runat="server">
<asp:CheckBox ID="chkCI" Text="CI" runat="server"></asp:CheckBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<p></p>
<asp:Table ID="tblStats" runat="server" Width="100%" CellSpacing="1" GridLines="None">
<asp:TableRow>
<asp:TableCell ID="tdpStats" Text="Rollover Status" ColumnSpan="6" runat="server"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="6">
<asp:Image ID="imgStats" runat="server"></asp:Image>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow CssClass="ColHeading">
<asp:TableCell ID="tdpTblNme" runat="server" Text="Table Name" Width="25%"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot" runat="server" Text="Source Total" Width="15%"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct" runat="server" Text="Source Inactive" Width="15%"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna" runat="server" Text="Source Active" Width="15%"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot" runat="server" Text="Target Active" Width="15%"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt" runat="server" Text="Batch Results" Width="15%"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat1" runat="server" CssClass="OddRow">
<asp:TableCell ID="tdpTblNme1" runat="server" Text="Program Year"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot1" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna1" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct1" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot1" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt1" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat2" runat="server" CssClass="EvenRow">
<asp:TableCell ID="tdpTblNme2" runat="server" Text="Sponsor Application"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot2" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna2" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct2" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot2" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt2" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat2a" runat="server" CssClass="EvenRow">
<asp:TableCell ID="tdpTblNme2a" runat="server" Text=" Sponsor App A"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot2a" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna2a" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct2a" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot2a" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt2a" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat2b" runat="server" CssClass="EvenRow">
<asp:TableCell ID="tdpTblNme2b" runat="server" Text=" Sponsor App B"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot2b" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna2b" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct2b" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot2b" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt2b" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat2c" runat="server" CssClass="EvenRow">
<asp:TableCell ID="tdpTblNme2c" runat="server" Text=" Sponsor App C"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot2c" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna2c" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct2c" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot2c" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt2c" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat2d" runat="server" CssClass="EvenRow">
<asp:TableCell ID="tdpTblNme2d" runat="server" Text=" Sponsor App D"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot2d" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna2d" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct2d" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot2d" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt2d" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat3" runat="server" CssClass="OddRow">
<asp:TableCell ID="tdpTblNme3" runat="server" Text="Sponsor Location"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot3" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna3" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct3" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot3" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt3" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat4" runat="server" CssClass="EvenRow">
<asp:TableCell ID="tdpTblNme4" runat="server" Text="Product Cost"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot4" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna4" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct4" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot4" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt4" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat5" runat="server" CssClass="OddRow">
<asp:TableCell ID="tdpTblNme5" runat="server" Text="Program Enrollment"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot5" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna5" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct5" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot5" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt5" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat6" runat="server" CssClass="EvenRow">
<asp:TableCell ID="tdpTblNme6" runat="server" Text="Entity Xref"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot6" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna6" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct6" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot6" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt6" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat7" runat="server" CssClass="OddRow">
<asp:TableCell ID="tdpTblNme7" runat="server" Text="County Region Xref"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot7" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna7" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct7" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot7" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt7" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="tbrStat8" runat="server" CssClass="EvenRow">
<asp:TableCell ID="tdpTblNme8" runat="server" Text="Warehouse Region Xref"></asp:TableCell>
<asp:TableCell ID="tdpSrcTot8" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcIna8" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpSrcAct8" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpTrgTot8" runat="server" HorizontalAlign="Right"></asp:TableCell>
<asp:TableCell ID="tdpRollCnt8" runat="server" HorizontalAlign="Right"></asp:TableCell>
</asp:TableRow>
</asp:Table>
<p></p>
<asp:Table ID="tblSummary" runat="server" Width="100%" CellSpacing="1" GridLines="None">
<asp:TableRow>
<asp:TableCell ID="tdpSummary" Text="Rollover Summary" ColumnSpan="2" runat="server"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="2">
<asp:Image ID="imgSummary" runat="server"></asp:Image>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="tdpBatchNbr" runat="server" Text="Batch Number:" Width="20%"></asp:TableCell>
<asp:TableCell ID="tddBatchNbr" runat="server" Text="1004"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="tdpBatchCount" runat="server" Text="Records Added:"></asp:TableCell>
<asp:TableCell ID="tddBatchCount" runat="server" Text="12,452"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="tdpBatchStart" runat="server" Text="Start Time:"></asp:TableCell>
<asp:TableCell ID="tddBatchStart" runat="server" Text="10:05:00"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="tdpBatchEnd" runat="server" Text="End Time:"></asp:TableCell>
<asp:TableCell ID="tddBatchEnd" runat="server" Text="10:07:45"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="tdpBatchTime" runat="server" Text="Total Time:"></asp:TableCell>
<asp:TableCell ID="tddBatchTime" runat="server" Text="00:02:45"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="tdpBatchDte" runat="server" Text="End Date:"></asp:TableCell>
<asp:TableCell ID="tddBatchDte" runat="server" Text=""></asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Table ID="tblViewLog" runat="server" Width="100%" CellSpacing="1" GridLines="None" BorderWidth="2"
BorderStyle="Solid">
<asp:TableRow>
<asp:TableCell ID="tdpViewLog" Text="Rollover Log" ColumnSpan="2" runat="server"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="2">
<asp:Image ID="imgViewLog" runat="server"></asp:Image>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ID="txtViewLogData" runat="server" Text="Log Data Here"></asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Table ID="tblButton" runat="server" Width="100%">
<asp:TableRow>
<asp:TableCell>
<asp:Image runat="server" ID="imgBottom"></asp:Image>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign="Center">
<asp:Button runat="server" ID="btnSubmit" Text="Run Rollover"></asp:Button>
<asp:Button runat="server" ID="btnCancel" Text="Cancel"></asp:Button>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<%----%>
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Looking at the ChangePass.ascx, it is a control so the following tag is incorrect:
<%@ Page Language="c#" CodeBehind="ChangePass.ascx.cs" AutoEventWireup="false" Inherits="DIS.CnpWeb.Core.ChangePass" %>
it should be:
<%@ Control Language="c#" AutoEventWireup="false" CodeFile="ChangePass.ascx.cs"
Inherits="DIS.CnpWeb.Core.ChangePass" %>
don't know if this will fix your error but this can be leading up to the issue.
|
|
|
|
|
Hey Guys
i have to create a webpage that has a button and gridview, once the button is pressed it triggers the click button method which searches my computer for files in a specific folder once files are found it displays it in the grid view .
which i have managed to do my problem is im expected to then give the ability that if the user clicks on the file name(which is a hyperlink) in the grid view that it opens on a new page and that the file is embed in that page ready for viewing??
i have tried all i can think off.
ps the files not in a db they in a folder on my pc later will be on a sever in a folder
hope some on can help me
here is what i have so far
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="119px" >
<Columns>
<asp:TemplateField HeaderText="FileName">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Dir","~/Dir={0}")%>' Text='<%# Eval("File") %>' PostBackUrl="/WebForms4.aspx"> </asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="size" HeaderText="size" />
<asp:TemplateField HeaderText="diretory">
<ItemTemplate>
<asp:Button ID="Button2" runat="server" CommandArgument='<%# Eval("Dir","~/WebForms4.aspx/files?Dir={0}") %>' Text='<%# Eval("Dir") %>' PostBackUrl="~/WebForms4.aspx?Dir={0}" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
and C# code
protected void Button1_Click(object sender, EventArgs e)
{
DataTable Dt = new DataTable();
Dt.Columns.Add("File", typeof(string));
Dt.Columns.Add("Size", typeof(string));
Dt.Columns.Add("Dir", typeof(string));
foreach (string filename in Directory.GetFiles(@"C:\files"))
{
FileInfo fileinfo = new FileInfo(filename);
Dt.Rows.Add(fileinfo.Name, fileinfo.Length +"KB", fileinfo.FullName);
}
GridView1.DataSource = Dt;
GridView1.DataBind();
}
Thanks in advanced
|
|
|
|
|
please explain me how to insert images to word document created through .net
|
|
|
|
|
|
Hi, I have written a control that inherits from DataBoundControl
[ToolboxData("<{0}:MyClass runat=server></{0}:MyClass>")]
[Designer(typeof(MyClassDesigner))]
[ToolboxItem(true)]
public class MyClass: DataBoundControl
Problem is, when I try to drag it from the toolbox to the page, the mouse cursor changes to an icon that represents it's not allowed(circle with diagonal line through it). How do I make my control support that? The control works just fine if I manually type it in the page.
What am I forgetting? Any ideas?
|
|
|
|
|
Dear all,
When I call 'api/values', it only allows me login as 'full' user details, but if a login as 'trial' user login details, it throws a 401 error. I would like to ask, if I am missing something in the queries in the user class below or the basicAuthn class:
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
AuthenticationHeaderValue authValue = request.Headers.Authorization;
if (authValue == null || authValue.Scheme != BasicAuthResponseHeaderValue)
{
return Unauthorized(request);
}
string[] credentials = Encoding.ASCII.GetString(Convert.FromBase64String(authValue.Parameter)).Split(new[] { ':' });
if (credentials.Length != 2 || string.IsNullOrEmpty(credentials[0]) || string.IsNullOrEmpty(credentials[1]))
{
var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
{
Content = new StringContent(string.Format("access denied")),
};
}
ClaimRole user = repository.trial(credentials[0], credentials[1]);
ClaimRole user2 = repository.unlim(credentials[0], credentials[1]);
if (user == null || user2 == null)
{
var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
{
Content = new StringContent(string.Format("access denied")),
};
}
else
{
IPrincipal principal = new GenericPrincipal(new GenericIdentity(user.Username, BasicAuthResponseHeaderValue), new string[] { user.role });
Thread.CurrentPrincipal = principal;
HttpContext.Current.User = principal;
}
return base.SendAsync(request, cancellationToken);
}
User Class
public ClaimRole trial(string username, string password)
{
var query = (from s in db.subs
join u in db.user on s.sUID equals u.uID
where s.sExpiryDate >= DateTime.Now &&
u.uUsername == username &&
u.uPassword == password
select u).FirstOrDefault();
if (query != null)
{
return new ClaimRole { Username = query.uUsername, Password = query.uPassword, role = "Trial" };
}
else
{
return null;
}
}
public ClaimRole full(string username, string password)
{
var query = (from s in db.subs
join u in db.user on s.sUID equals u.uID
where s.sPID.Value == 163 &&
u.uUsername == username &&
u.uPassword == password
select u).FirstOrDefault();
if (query != null)
{
return new ClaimRole { Username = query.uUsername, Password = query.uPassword, role = "full" };
}
else
{
return null;
}
}
Please advise
many thanks
|
|
|
|
|
I guess the problem is here:
ClaimRole user = repository.trial(credentials[0], credentials[1]);
ClaimRole user2 = repository.unlim(credentials[0], credentials[1]);
if (user == null || user2 == null)
If the user does not have BOTH the trial and unlim priviledges, you send the Access Denied message.
Use && isntead of || .
|
|
|
|
|
Thank you so much for your response and help. I am sorry to inform, that i have tried using the '&&' operator but I am still getting the same 401 error, when logging in using full query user details.
i would like to ask, if their is certain parameter and method, i should be looking into while debugging the code.
I really appreciated your help. please advise.
Many thanks.
|
|
|
|
|
then test those two repository.trail / repository.unlim functions. At least one of them has a bug.
|
|
|
|
|
Thank you for your feedback. i am stuck on little status code issue, regarding this long problem. When I debug the full and trial repository, while login as 'trail' user, 'resp' variable below is highlighted as red with a 404 status code, but on the fiddler testing environment, it displays the url as 401 unauthorized issue.
ClaimRole user = repository.trial(credentials[0], credentials[1]);
ClaimRole user2 = repository.full(credentials[0], credentials[1]);
if (user == null || user2 == null)
{
var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
{
Content = new StringContent(string.Format("access denied")),
};
}
else
{
<br />
resp -- {StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
Hence I am little unclear, which error to look into. if you get time, could you please advice on any material i should look into or concentrate on.
Many thanks for your time and help.
|
|
|
|
|
As of now,Popup in a page asks for password and onclick jquery ajax method calls webmethod, which returns the actual password of the user for validation.
But if a press F12,the password gets viewed as response .
Note:- After buttonclick, page needs to redirect to the same page.
|
|
|
|
|
Never send a password back to the client. The program should send the user's input to the server side for validation. Not the other way round.
|
|
|
|
|
Apart from the fact that you shouldn't be sending the user's password to an unauthenticated client, you shouldn't be able to send the user's password, ever.
Passwords should NEVER be stored in plain text.
You should be storing a salted hash of the password. When you need to verify the entered password, you apply the same salting and hashing algorithm to the entered password, and compare the result to the stored salted hash of the real password.
See Salted Password Hashing - Doing it Right[^] for more information.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi All,
I am trying to write repeater values in to Excel file, it is writing something but it not writing clearly. Can anybody please help where am I doing mistake. Another problem is repeater control has text boxes and td values. Initially I couldn't write into excel because of text boxes then I did this work around but didn't give me the solution I want.
Here is my code:
protected void ExportToExcel(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AddHeader("Content-Disposition", "attachment;filename=" + ConfigurationManager.AppSettings["ExcelFilePath"].ToString() +
ddlProductId.Text + "_" + ddlProcessor.Text + ".xls");
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
HtmlForm frm = new HtmlForm();
this.Page.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(this.rptMonthlyReport);
frm.RenderControl(oHtmlTextWriter);
rptMonthlyReport.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{ }
public override bool EnableEventValidation
{
get { return false; }
set { }
}
Then I have out put displayed as below. Please help me in this regard. Any help link or code snippet or a suggestion would help me a bit. Thanks in advance.
input type+AD0AIg-hidden+ACI- name+AD0AIgBfAF8-VIEWSTATE+ACI- id+AD0AIgBfAF8-VIEWSTATE+ACI- value+AD0AIgAi- /+AD4- +ADw-/div+AD4- +ADw-header+AD4- +ADw-span id+AD0AIg-rptMonthlyReport+AF8-Label3+ACI- class+AD0AIg-FormHead2+ACIAPg-Monthly Performance Report Tracking+ADw-/span+AD4- +ADw-/header+AD4- +ADw-table width+AD0AIg-100+ACUAIg- id+AD0AIg-tblMonthlyReport+ACI- cellspacing+AD0AIg-2+ACI- border+AD0AIg-1+ACIAPg- +ADw-tr+AD4- +ADw-td class+AD0AIg-ColHeading+ACIAPg-Recipient Agency+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-false+ACI- style+AD0AIg-width: 4+ACUAOwAiAD4- +ADw-span id+AD0AIg-rptMonthlyReport+AF8-lblCarryOverQty+ACI- class+AD0AIg-ColHeading+ACI- style+AD0AIg-display:inline-block+ADs-width:99+ACUAOwAiAD4-SY 2012-13+ADw-br /+AD4- Carry +ADw-br /+AD4-Over Pounds+ADw-/span+AD4APA-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-false+ACI- style+AD0AIg-width: 4+ACUAOwAiAD4- +ADw-span id+AD0AIg-rptMonthlyReport+AF8-lblDivertedQty+ACI- class+AD0AIg-ColHeading+ACI- style+AD0AIg-display:inline-block+ADs-width:99+ACUAOwAiAD4-Pounds +ADw-br /+AD4-Diverted for+ADw-br /+AD4-SY 2013-14+ADw-/span+AD4APA-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-Jul+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-Aug+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-Sep+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-Oct+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-Nov+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-Dec+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-Jan+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-Feb+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-Mar+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-Apr+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-May+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-true+ACI- style+AD0AIg-width: 4+ACUAIgA+-Jun+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- style+AD0AIg-width: 6+ACUAOw- flex-wrap: wrap+ADsAIgA+-Qty Trans Frm Sponr To State+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- style+AD0AIg-width: 6+ACUAOw- flex-wrap: wrap+ADsAIgA+-Qty Trans Frm State To Sponr+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- style+AD0AIg-width: 6+ACUAOw- flex-wrap: wrap+ADsAIgA+-Qty Trans Frm Sponr To Sponr+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- nowrap+AD0AIg-false+ACI- style+AD0AIg-width: 4+ACUAIgA+-Total+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- style+AD0AIg-width: 4+ACUAOw- flex-wrap: wrap+ADsAIgA+-Prior Yr Left Over+ADw-/td+AD4- +ADw-td class+AD0AIg-ColHeading+ACI- style+AD0AIg-width: 2+ACUAOw- flex-wrap: wrap+ADsAIgA+-Ext Ind+ADw-/td+AD4- +ADw-/tr+AD4- +ADw-tr class+AD0AIg-OddRow+ACI- width+AD0AIg-95+ACUAIgA+- +ADw-td align+AD0AIg-left+ACI- style+AD0AIg-border: none+ADsAIgA+- +ADw-input name+AD0AIg-rptMonthlyReport+ACQ-ctl16+ACQ-Hidden1+ACI- type+AD0AIg-hidden+ACI- id+AD0AIg-rptMonthlyReport+AF8-Hidden1+AF8-0+ACI- value+AD0AIg-10001+ACI- /+AD4- Baker SD 5J +ADw-/td+AD4- +ADw-td id+AD0AIg-rptMonthlyReport+AF8-tdCarryOverQty+AF8-0+ACI- align+AD0AIg-right+ACI- style+AD0AIg-width: 4+ACUAIgA+- +ADw-input name+AD0AIg-rptMonthlyReport+ACQ-ctl16+ACQ-txtCarryOverQty+ACI- type+AD0AIg-text+ACI- value+AD0AIg-0.00+ACI- id+AD0AIg-
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Try this
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=namefile.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
rep.RenderControl(htmlWrite);
Response.Write("<table>");
Response.Write(stringWrite.ToString());
Response.Write("</table>");
Response.End();
|
|
|
|
|
Hi,
Thank you for your help, it is working fine but the alignments are not that good. Like a column is taking lot of space but the other is not.
And I think it is taking Text boxes as it is in the excel file, is there any way to make everything as normal text and write those values in to excel file as just normal text.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Do you have text-boxes in repeater? while exporting data to excel i think there should textbox instead of that labels or Literals should be there,
|
|
|
|