|
Hi..Sorry for being too late.
After i added:
using System.Web.UI;
The build error disappeared but after i uploaded(updated) the project i got the error message:
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 12: <TR>
Line 13: <TD vAlign="middle" align="center">
Line 14: <asp:ImageButton id=ImageButton1 runat="server" OnCommand="gogof" ImageUrl='<%#"~/Epictures/"+DataBinder.Eval(Container.DataItem,"ProjectImage")%>' CommandArgument='<%#GenerateDataBinders(Container.DataItem,Container.ItemIndex)%>' CommandName="topf" BorderStyle="Solid" BorderColor="green">
Line 15: </asp:ImageButton></TD>
Line 16: </TR>
Source File: C:\Sites\Single25\nabeel1eagle\webroot\UserControls\FieldProjectsList.ascx Line: 14
The UserControl code:
namespace EProjects.UserControls
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for FieldProjectsList.
/// </summary>
public class FieldProjectsList : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DataList lProjects;
private void Page_Load(object sender, System.EventArgs e)
{
string searchString=Request.QueryString["SearchString"];
string allWords=Request.QueryString["AllWords"];
string pageNumber=Request.QueryString["PageNumber"];
if(searchString!=null && searchString!="")
{
allWords=Request.QueryString["AllWords"];
pageNumber=Request.QueryString["PageNumber"];
lProjects.DataSource=catalog.SearchProject(searchString,allWords,pageNumber,System.Threading.Thread.CurrentThread.CurrentCulture.Name);
lProjects.DataBind();
}
else
{
BindData();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lProjects.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.lProjects_ItemDataBound);
this.lProjects.SelectedIndexChanged += new System.EventHandler(this.lProjects_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public void gogof(object s,CommandEventArgs e)
{string searchString=Request.QueryString["SearchString"];
// string allWords=Request.QueryString["AllWords"];
/* if(searchString!=null)
{
lProjects.DataSource=catalog.SearchProject(searchString,allWords);
lProjects.DataBind();
}
else
BindData();*/
//string fieldNO=Request.QueryString["FieldNO"];
string fieldNO=Request.QueryString["FieldNO"];
string fieldIndex=Request.QueryString["FieldIndex"];
string allWords=Request.QueryString["AllWords"];
string pageNumber=Request.QueryString["PageNumber"];
//string allWords=Request.QueryString["AllWords"];
/* if(searchString!=null)
{
lProjects.DataSource=catalog.SearchProject(searchString,allWords,pageNumber,System.Threading.Thread.CurrentThread.CurrentCulture.Name);
lProjects.DataBind();
}
else
BindData();*/
string argu=e.CommandArgument.ToString();
string[] argss=argu.Split(',');
string projectNO;
string projectIndex;
if(e.CommandName=="topf")
{
// Trace.Warn("ProjectProblem",projectNO);
if(searchString!=null && searchString!="")
{
Trace.Warn("FieldProblem",argu);
projectNO=argss[0];
fieldNO=argss[1];
Response.Redirect("default.aspx?FieldNO="+fieldNO+"&ProjectNO="+projectNO);
}
else
{
//Trace.Warn("ProjectNO=",Convert.ToString(argu.IndexOf("+")+1));
// Trace.Warn("IndexProblem=",Convert.ToString(argu.IndexOf("_")));
fieldNO=Request.QueryString["FieldNO"];
fieldIndex=Request.QueryString["FieldIndex"];
projectIndex=argss[1];
projectNO=argss[0];
Response.Redirect("default.aspx?FieldNO="+fieldNO+"&FieldIndex="+fieldIndex+"&ProjectNO="+projectNO+"&ProjectIndex="+projectIndex);
}
}
}
public void BindData()
{
string fieldNO=Request.QueryString["FieldNO"];
lProjects.DataSource=EProjects.AdministratorSite.AdminCatalog.GetFieldProjects(fieldNO,System.Threading.Thread.CurrentThread.CurrentCulture.Name);
lProjects.DataBind();
}
private void lProjects_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
{
}
private void lProjects_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
public string GenerateDataBinders(object dataItem,int Index)
{string searchString=Request.QueryString["SearchString"];
string projectIndex;
string projectNO;
string fieldNO;
if(searchString!=null && searchString!="")
{
projectNO=(string)DataBinder.Eval(dataItem,"ProjectNO");
fieldNO=(string)DataBinder.Eval(dataItem,"FieldNO");
return projectNO+","+fieldNO;
}
else
{
Trace.Warn("PProjectNO=",Convert.ToString(Index));
projectNO=(string)DataBinder.Eval(dataItem,"ProjectNO");
projectIndex=Convert.ToString(Index);
return projectNO+","+projectIndex;
}
}
}
}
its HTML :
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="FieldProjectsList.ascx.cs" Inherits="EProjects.UserControls.FieldProjectsList" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<asp:datalist id="lProjects" Width="100%" RepeatColumns="2" runat="server">
<ItemTemplate>
<TABLE height="100%" cellPadding="0" width="100%">
<TR>
<TD align="center">
<asp:Label id="Label1" NAME="Label1" Runat="server" CssClass="labelstyle">
<%#DataBinder.Eval(Container.DataItem,"ProjectName")%>
</asp:Label><BR>
</TD>
</TR>
<TR>
<TD vAlign="middle" align="center">
<asp:ImageButton id=ImageButton1 runat="server" OnCommand="gogof" ImageUrl='<%#"~/Epictures/"+DataBinder.Eval(Container.DataItem,"ProjectImage")%>' CommandArgument='<%#GenerateDataBinders(Container.DataItem,Container.ItemIndex)%>' CommandName="topf" BorderStyle="Solid" BorderColor="green">
</asp:ImageButton></TD>
</TR>
<TR>
<TD align="center">
<asp:Label id="Label2" NAME="Label2" Runat="server">
<%#DataBinder.Eval(Container.DataItem,"ProjectDescription")%>
</asp:Label><BR>
</TD>
</TR>
</TABLE>
</ItemTemplate>
</asp:datalist>
I think that the problem in using the Container.ItemIndex.I have made it (int) and beforethis i tried making it object but the same error appeared.
You have helped me all the time thank you very much my teacher.
|
|
|
|
|
Hi..
May you help me in the problem that i mentioned in the previous message?
I couldnt determine what cause that error message..
Any advice could be helpful.
|
|
|
|
|
thanks in advance to all,i got a login from in my application.so i have to textboxes fro user name and password.i have required field validation control for both the text boxes.i have set control to validate and every thing that's working fine.so i got a button control to submit the information of the textboxes.when im clicking the button that validation working fine.my problem is i got another one link button in that page if i click that,that time also my validation controls get called and check for the data in the textboxes.i want to stop this .please help me.
with regards,
susa
|
|
|
|
|
+ If you are using the ASP.NET 2.0, you should check out the ValidationGroup[^] feature.
+ If you are using the ASP.NEt 1.x, you may think of implementing your own validator.
|
|
|
|
|
im using asp.net 1.x and im not having my own validation control and im using asp.net required field validators.
with regards,
susa
|
|
|
|
|
Set CausesValidation Property of the LinkButton to False
"Aim to go where U have never been B4 and Strive to achieve it"
http://groups.yahoo.com/subscribe/dotnetforfreshers
http://himabinduvejella.blogspot.com
|
|
|
|
|
hi thank u hima it's working now
hi to all
with regards,
susa
|
|
|
|
|
I have a delivery page (binded to an Orders.mdf) that looks something like this. A simple webform that only handle ONE KIND of product but has various weights.
[lblDate] = shows the date selected, receive user selected date from the Calendar control.
[txtDeliveryOrderNo] = clerk types in a Delivery Order No.
[ddlPort] = dropdownlist showing a list of sea port where goods are imported, databound to a SQL ports.mdf
[ddlCustomer] = dropdownlist showing a list of customer, by name. Place where goods are delivered. Databound to a SQL customers.mdf
[ddlTruck] = dropdownlist showing which truck does the delivery
[txtGrossWeight] = user enter the gross weight of the item here and then click on an "ADD ITEM" button control to store record. Can have multiple items.
[btnSave] = saves the order record to the orders.mdf.
[btnCancel] = cancel the order record.
Is there anyone who can gimme a rough idea of how this could be done? Or has anyone done it before? I need it in C# codes.
|
|
|
|
|
|
I have a Product Order page. A user can order many products. To simplify it, user can just type the word "beer" into a textbox and click on ADD button, cookies and click on ADD button again, socks and click on ADD button again into a database. So, a database will show:
UserID
UserName
OrderID
Product List (Beer, Cookies, Socks)
After the user decides on the list of things to buy. Then the user click on SAVE, to save that record (with multiple items) to another database.
Very much like ADD TO CART concept. Anyone can guide me with this? How should I go about it?
There are a lot of people who ended up doing things wrongly, even if they had the best of intentions at the beginning. Then again, there is no guarantee the words they said were conveyed as they originally were intended to be. That's because those on the receiving end only hear what they want to hear.
|
|
|
|
|
What I have is a web page, that allows you to select 1 of 12 possible options. When one of these 12 options are selected I want the web form that it loads to dynamically choose a flash movie file based on the selection.
Here is my code in HTML
<code><OBJECT id="Banner" style="Z-INDEX: 147; LEFT: 93px; POSITION: absolute; TOP: 158px" codeBase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" height="100" width="748" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" VIEWASTEXT>
<PARAMNAME="_cx" VALUE="19791">
<PARAM NAME="_cy" VALUE="2646">
<PARAM NAME="FlashVars" VALUE="">
<PARAM NAME="Movie" VALUE="Banner.swf">
<PARAM NAME="Src" VALUE="Banner.swf">
<PARAM NAME="WMode" VALUE="Window">
<PARAM NAME="Play" VALUE="-1">
<PARAM NAME="Loop" VALUE="-1">
<PARAM NAME="Quality" VALUE="High">
<PARAM NAME="SAlign" VALUE="">
<PARAM NAME="Menu" VALUE="-1">
<PARAM NAME="Base" VALUE="">
<PARAM NAME="AllowScriptAccess" VALUE="sameDomain">
<PARAM NAME="Scale" VALUE="ShowAll">
<PARAM NAME="DeviceFont" VALUE="0">
<PARAM NAME="EmbedMovie" VALUE="0">
<PARAM NAME="BGColor" VALUE="FFFFFF">
<PARAM NAME="SWRemote" VALUE="">
<PARAM NAME="MovieData" VALUE="">
<PARAM NAME="SeamlessTabbing" VALUE="1">
<PARAM NAME="Profile" VALUE="0">
<PARAM NAME="ProfileAddress" VALUE="">
<PARAM NAME="ProfilePort" VALUE="0">
<embed src="Banner.swf" width="748" height="100" align="middle" />
</OBJECT></code>
***************************************************
Now as you can see..."<embed src="Banner.swf"....
.<PARAM NAME="Movie" VALUE="Banner.swf">..
...<PARAM NAME="Src" VALUE="Banner.swf">.
...<OBJECT id="Banner"....."
These are all pointing at "BANNER.SWF"....but in code I would like to dynamically change those tags to "BANNER2.SWF", "BANNER3.SWF"...etc etc based on the users choice.
I have tried using the "HtmlGenericControl" to try and change these during run time but not sucessfully.
Any help would be appreciated.
-- modified at 19:20 Sunday 23rd April, 2006
|
|
|
|
|
IMO, there are two options which you may consider using to dynamically change the media file.
+ Use the client side script, you can get reference to the player(for example with the getElementById method), then change the Src property of the player.
+ Use the server side script, you will re-render the player with the new html markup which contains a new media file for the src parameter.
|
|
|
|
|
Can we replace Customer control instead of user control?
|
|
|
|
|
did you mean custom controls ?
|
|
|
|
|
Assuming you mean the custom control, then yes you can use the custom control in lieu of the web user control. However depending on your context, using custom control or user control should be easier, you can see the recommendation in MSDN[^].
|
|
|
|
|
Both has its own advantages
We can use either but it all depends on our requirement
"Aim to go where U have never been B4 and Strive to achieve it"
http://groups.yahoo.com/subscribe/dotnetforfreshers
http://himabinduvejella.blogspot.com
|
|
|
|
|
I haven't done much ASP.Net so I hope this is a small problem:
I have a page where the users can log in to the website. Their role depends on what page they get redirected to, so I am handeling the LoggedIn event of the Login control:
protected void Login_LoggedIn(object sender, EventArgs e)
{
if (User.IsInRole("Admin") == true)
{
Server.Transfer("Admin/Default.aspx");
}
else if (User.IsInRole("SuperAdmin") == true)
{
Server.Transfer("SuperAdmin/Default.aspx");
}
else
{
Server.Transfer("User/Default.aspx");
}
}
I have no idea if this is the best way to do someting like this... But my problem is that when, let's say the Admin, loggs in they will get the user page(supposed to be admin's) the first time and it says that they have not been authenticated. However, if i hit back and login again it says that they have been authenticated and it goes to the right page.
Anyone have any ideas why this is hapening?
Thanks in advance
-- modified at 13:33 Sunday 23rd April, 2006
|
|
|
|
|
+ You should use the Response.Redirect method instead of the Transfer method to redirect the user to the default page.
+ Another option that you can try in the handler of the LoggedIn event handler is that after you determine the default web page based on the user role, you then simply assign the web page to the DestinationPageUrl property of the Login control, and have the control do the rest.
|
|
|
|
|
I dont think you are understanding my question. The user is not getting directed to the right page because they are not being authenticated when they hit login.
I put:
Response.Write(User.IsAuthenticated.ToString());
on the page that the user kept getting directed to after they logged in and it says false.
So for some reason, its not authenticating the user the first time they login. Which is weird because I have made it so that you need to be logged in before you can access the user page and yet it is letting them go there. So its a bit odd
Furthermore, when I switch Server.Transfer to Response.Redirect it keeps sending the user back to the login page!!?
Any ideas?
|
|
|
|
|
Sean89 wrote: I dont think you are understanding my question.
I'm sorry.
Sean89 wrote: Any ideas?
IMO, there are a couple of reasons as to why the application sends the user back to the login page:
+ The username/password is not correct (might not be this case).
+ The user account is not authorised to view the web page in the Admin or SuperAdmin folder. So could you double check the authorization settings of your application, especially for the Admin/SuperAdmin folder.
+ The authentication ticket is not added.
Have you tried to debug your application and step through your sample code line by line and see what is actually happening?
|
|
|
|
|
please check with the ispostback is true or false
with regards,
susa
|
|
|
|
|
this is the entry in db
<span id="Label1" style="font-family:Arial Narrow;font-size:XX-Large;font-weight:bold;font-style:italic;text-decoration: overline;">
Now when i retrieve in source code
string str = ds.Tables[0].Rows[1][1].ToString();
my str value contains the following value, where i found extra slashes with each quote, plus two extra quotes at the each end of the string
"<span id=\"Label1\" style=\"font-family:Arial Narrow;font-size:XX-Large;font-weight:bold;font-style:italic;text-decoration: overline;\">"
how to get rid of these quotes and slashes?
|
|
|
|
|
How do you reckon that value looks like that? Are you singe stepping through the code and looking at the watch windows?
That's the way you would write that string as a string constant, so that's how it's displayed.
---
b { font-weight: normal; }
|
|
|
|
|
>>How do you reckon that value looks like that? Are you singe stepping through the code and looking at the watch windows?
As i didn't get the desired result, so i stepped through the code looking at the watch window, and encounter these extra stuff.
>>That's the way you would write that string as a string constant, so that's how it's displayed.
sorry, i couldn't understand this.
|
|
|
|
|
sinanju wrote: >>That's the way you would write that string as a string constant, so that's how it's displayed.
sorry, i couldn't understand this.
An example:
If you have this text:
Text with "funny" characters.
and put that in a string in the code, it would be written:
string s = "Text with \"funny\" characters."
This is the way that the watch windows show it. It does so to be able to show unprintable characters like line breaks.
---
b { font-weight: normal; }
|
|
|
|