Thursday, March 29, 2012
newbie: Help, I have problems with this!
asp.net 2.0
visual web developer 2005 express
I have a webpage which contains 1 Repeater control. Into this repeater
control I want to add several rows of data. My problem is that 1 of the data
is an array of bytes (it's a picture saved to the database as bytes) and I
want that picture to be displayed nicely in the repeater list...
Here is two approaches (approach A and approach B) I'm trying:
APPROACH A:
Use the scenario of 2 .aspx files, 1 .aspx (A) convert the bytes of array
into a picture and the other .aspx file (B) has a img tag pointing to the
first .aspx file (A)
But here I get problems with this line "img.Src =
"Thumnail.aspx?ImageID=1";", it looks like it expects a object... Somehow I
need to send over a parameter to this Thumbnail.aspx file about which image
to display... Lets say the resultset has many images, but this row shall
display one particular image
protected void rptInbox_ItemDataBound(object sender, RepeaterItemEventArgs
e)
{
System.Web.UI.HtmlControls.HtmlImage img = null;
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType ==
ListItemType.AlternatingItem)) {
img =
(System.Web.UI.HtmlControls.HtmlImage)e.Item.FindControl("Photo");
img.Src = "Thumnail.aspx?ImageID=1";
}
}
<%@dotnet.itags.org. Page Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="inbox.aspx.cs"
Inherits="webForms_Profile_inbox" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="content" Runat="Server">
<asp:ObjectDataSource ID="odsInbox" runat="server"
SelectMethod="getInbox" TypeName="BusinessLogic.NetworkLogic">
</asp:ObjectDataSource>
<asp:Repeater ID="rptInbox" runat="server" DataSourceID="odsInbox"
OnItemDataBound="rptInbox_ItemDataBound">
<ItemTemplate>
<tr>
<td bgcolor="#CCFFCC">
<%# Eval("Name") %>
<img ID="Photo" src="http://pics.10026.com/?src=" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="sidebar" Runat="Server">
</asp:Content>
****************************************
************************
APPROACH B:
In this approach I tryed to replace the img tag with a Image control in the
repeater.
But the "System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(mstream);"
gives this error:
"Parameter is not valid."
Another thing is that I'm not sure this is a good approach because it uses
bmp.Save() and I'm afraid the server will run out of space if images get
saved on the server each time th page is displayed?
protected void rptInbox_ItemDataBound(object sender, RepeaterItemEventArgs
e)
{
//System.Web.UI.HtmlControls.HtmlImage img = null;
System.Web.UI.WebControls.Image img = null;
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType ==
ListItemType.AlternatingItem)) {
img =
(System.Web.UI.WebControls.Image)e.Item.FindControl("Photo");
byte[] data = Profile.Picture;
Int32 offset = 78;
System.IO.MemoryStream mstream = new System.IO.MemoryStream();
mstream.Write(data, offset, data.Length - offset);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(mstream);
bmp.Save(Server.MapPath("sample.jpeg"),
System.Drawing.Imaging.ImageFormat.Jpeg);
mstream.Close();
img.ImageUrl = Server.MapPath("sample.jpeg");
}
//e.Item.DataItem.ToString();
}
Please help me with this one, I'm stucked in this problem...
Best Regards
Jeffhi Jeff
I think I've covered this in a previous thread, but anyways
on this page is an example of dynamically displaying binary image data
on a Web page. this uses a GridView but the logic's the same
http://authors.aspalliance.com/aspx...classbinarywri=
te.aspx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
Reynald V. Nu=F1ez
http://authors.aspalliance.com/aspxtreme
newbie: Help, I have problems with this!
asp.net 2.0
visual web developer 2005 express
I have a webpage which contains 1 Repeater control. Into this repeater
control I want to add several rows of data. My problem is that 1 of the data
is an array of bytes (it's a picture saved to the database as bytes) and I
want that picture to be displayed nicely in the repeater list...
Here is two approaches (approach A and approach B) I'm trying:
APPROACH A:
Use the scenario of 2 .aspx files, 1 .aspx (A) convert the bytes of array
into a picture and the other .aspx file (B) has a img tag pointing to the
first .aspx file (A)
But here I get problems with this line "img.Src =
"Thumnail.aspx?ImageID=1";", it looks like it expects a object... Somehow I
need to send over a parameter to this Thumbnail.aspx file about which image
to display... Lets say the resultset has many images, but this row shall
display one particular image
protected void rptInbox_ItemDataBound(object sender, RepeaterItemEventArgs
e)
{
System.Web.UI.HtmlControls.HtmlImage img = null;
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType ==
ListItemType.AlternatingItem)) {
img =
(System.Web.UI.HtmlControls.HtmlImage)e.Item.FindC ontrol("Photo");
img.Src = "Thumnail.aspx?ImageID=1";
}
}
<%@dotnet.itags.org. Page Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="inbox.aspx.cs"
Inherits="webForms_Profile_inbox" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="content" Runat="Server">
<asp:ObjectDataSource ID="odsInbox" runat="server"
SelectMethod="getInbox" TypeName="BusinessLogic.NetworkLogic">
</asp:ObjectDataSource>
<asp:Repeater ID="rptInbox" runat="server" DataSourceID="odsInbox"
OnItemDataBound="rptInbox_ItemDataBound">
<ItemTemplate>
<tr>
<td bgcolor="#CCFFCC">
<%# Eval("Name") %>
<img ID="Photo" src="http://pics.10026.com/?src=" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="sidebar" Runat="Server">
</asp:Content>
************************************************** **************
APPROACH B:
In this approach I tryed to replace the img tag with a Image control in the
repeater.
But the "System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(mstream);"
gives this error:
"Parameter is not valid."
Another thing is that I'm not sure this is a good approach because it uses
bmp.Save() and I'm afraid the server will run out of space if images get
saved on the server each time th page is displayed?
protected void rptInbox_ItemDataBound(object sender, RepeaterItemEventArgs
e)
{
//System.Web.UI.HtmlControls.HtmlImage img = null;
System.Web.UI.WebControls.Image img = null;
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType ==
ListItemType.AlternatingItem)) {
img =
(System.Web.UI.WebControls.Image)e.Item.FindContro l("Photo");
byte[] data = Profile.Picture;
Int32 offset = 78;
System.IO.MemoryStream mstream = new System.IO.MemoryStream();
mstream.Write(data, offset, data.Length - offset);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(mstream);
bmp.Save(Server.MapPath("sample.jpeg"),
System.Drawing.Imaging.ImageFormat.Jpeg);
mstream.Close();
img.ImageUrl = Server.MapPath("sample.jpeg");
}
//e.Item.DataItem.ToString();
}
Please help me with this one, I'm stucked in this problem...
Best Regards
Jeffhi Jeff
I think I've covered this in a previous thread, but anyways
on this page is an example of dynamically displaying binary image data
on a Web page. this uses a GridView but the logic's the same
http://authors.aspalliance.com/aspx...inarywrite.aspx
==============================
Reynald V. Nuez
http://authors.aspalliance.com/aspxtreme
Newbie: How do I install a control in order to use it?
JosenAre you talking about a 3rd party control?
Yes. I want to use the control at the following link...
http://scottonwriting.net/demos/RoundedCorners.aspx
It really depends on your editor - -
if you're using VS.Net - you right click on the tools section and add the new control into your project.
If you're just using a text editor - copy the dll you download, into your bin directory and inside your aspx page - just use the markup they have on that page and change the appearance the way you need.
That's what I was looking for...
Thanks,
Josen
Oh... what's the full path to the bin directory?
The bin folder is placed in the root directory of your website.
your bin directory should be at the root of your web application.
/bin/
Rounded corners is pretty sweet, I started using it the past few days.
You can also open windows explorer and find the .dll and drag it onto your vs.net toolbox.
Newbie: How to compare strings?
On my drop down list control, i am trying to set the
DropDownList1.SelectedValue property to the selected string value. In my
example, my DropDownList1 control contains three colors:
- Carlos
- Mike
- Susan
However, if i try to set the DropDownList1.SelectedValue = "carlos"; i get
the following error: "Exception: Specified argument was out of the range of
valid values. Parameter name: carlos." This is b/c "Carlos" != to "carlos".
I realize that i can convert all the drop down list controls values to
uppercase, however, i'd like to keep the names as they are entered by the
user.
Is there anyway to compare these strings, ignoring any differences in
uppercase or lowercase?
Thanks!String.Compare("CARLOS", "carlos", true);
-Brock
DevelopMentor
http://staff.develop.com/ballen
> Hi,
> On my drop down list control, i am trying to set the
> DropDownList1.SelectedValue property to the selected string value. In
> my example, my DropDownList1 control contains three colors:
> - Carlos
> - Mike
> - Susan
> However, if i try to set the DropDownList1.SelectedValue = "carlos"; i
> get the following error: "Exception: Specified argument was out of the
> range of valid values. Parameter name: carlos." This is b/c "Carlos"
> != to "carlos".
> I realize that i can convert all the drop down list controls values to
> uppercase, however, i'd like to keep the names as they are entered by
> the user.
> Is there anyway to compare these strings, ignoring any differences in
> uppercase or lowercase?
> Thanks!
Newbie: How to compare strings?
On my drop down list control, i am trying to set the
DropDownList1.SelectedValue property to the selected string value. In my
example, my DropDownList1 control contains three colors:
- Carlos
- Mike
- Susan
However, if i try to set the DropDownList1.SelectedValue = "carlos"; i get
the following error: "Exception: Specified argument was out of the range of
valid values. Parameter name: carlos." This is b/c "Carlos" != to "carlos".
I realize that i can convert all the drop down list controls values to
uppercase, however, i'd like to keep the names as they are entered by the
user.
Is there anyway to compare these strings, ignoring any differences in
uppercase or lowercase?
Thanks!String.Compare("CARLOS", "carlos", true);
-Brock
DevelopMentor
http://staff.develop.com/ballen
> Hi,
> On my drop down list control, i am trying to set the
> DropDownList1.SelectedValue property to the selected string value. In
> my example, my DropDownList1 control contains three colors:
> - Carlos
> - Mike
> - Susan
> However, if i try to set the DropDownList1.SelectedValue = "carlos"; i
> get the following error: "Exception: Specified argument was out of the
> range of valid values. Parameter name: carlos." This is b/c "Carlos"
> != to "carlos".
> I realize that i can convert all the drop down list controls values to
> uppercase, however, i'd like to keep the names as they are entered by
> the user.
> Is there anyway to compare these strings, ignoring any differences in
> uppercase or lowercase?
> Thanks!
>
Newbie: Javascript help
user enters a given character (say "?") into a textbox server control please?
Thank youIn the .aspx page (did not check it running):
<head>
...
function checkKey(){
if (window.event.keyCode==63)
myForm.submit();
else
return true;
}
...
</head>
<body>
<form id=myForm ...?>
...
<asp:textbox ... onkeypress="return checkKey();" ... />
...
</form></body
Eliyahu
"MikeH" <MikeH@.community.nospam> wrote in message
news:BE91A000-8D92-448E-9B03-CC531DF85F8D@.microsoft.com...
> What js code is required to automatically submit a page to the server when
a
> user enters a given character (say "?") into a textbox server control
please?
> Thank you
newbie: load image from db + Repeater
asp.net 2.0
With the help of a Repeater control on my webpage I want to dynamically
generate a list which contains both images and text field. This data are
stored in the aspnetdb.mdf database.
I know it's possible to have the imag tag to point to a .aspx file (<img
src="getImage.aspx" /> )
This is the Page_Load event I have in my getImage.aspx file
protected void Page_Load(object sender, EventArgs e)
{
if (Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}
}
The getImage.aspx file above is used another place in my project. My PROBLEM
is that I don't know how to adapt (make another version of getImage.aspx
which suit the repeater) this getImage.aspx file into the Repeater control.
More specific: in the Page_Load event of getImage.aspx you see that I'm
setting some properties of the Response object with some values of the
Profile object. But in the new getImage.aspx file (created specially for the
Repeater control) I must for each line in the Repeater control pass over the
correct ID to the Page_Load event so the getImage.aspx file knows what image
to load!
In other words how can I tell the Page_Load event what image to show. I
think about using a paramter. But my problem is that I don't know how to add
such a parameter. Maybe it could be passed in the EventArgs argument.. I'm
not sure...
Instead of sending the picture ID I could send over the bytes representing
the image. But even that, I (As Far As I Know) still have to send a paramter
to the Page_Load event
Any ideas how I should pass over such a parameter?
Jeffhello Jeff
you can track the id's and do something like getImage ( id ) in the
ItemDataBound event.
on this page is a similar example, though uses a GridView instead, but
logically it's the same
http://authors.aspalliance.com/aspx...te.aspx
Monday, March 26, 2012
newbie: load image from db + Repeater
asp.net 2.0
With the help of a Repeater control on my webpage I want to dynamically
generate a list which contains both images and text field. This data are
stored in the aspnetdb.mdf database.
I know it's possible to have the imag tag to point to a .aspx file (<img
src="getImage.aspx" />)
This is the Page_Load event I have in my getImage.aspx file
protected void Page_Load(object sender, EventArgs e)
{
if (Profile.Picture != null)
{
Response.ContentType = Profile.PictureType;
Response.BinaryWrite(Profile.Picture);
Response.End();
}
}
The getImage.aspx file above is used another place in my project. My PROBLEM
is that I don't know how to adapt (make another version of getImage.aspx
which suit the repeater) this getImage.aspx file into the Repeater control.
More specific: in the Page_Load event of getImage.aspx you see that I'm
setting some properties of the Response object with some values of the
Profile object. But in the new getImage.aspx file (created specially for the
Repeater control) I must for each line in the Repeater control pass over the
correct ID to the Page_Load event so the getImage.aspx file knows what image
to load!
In other words how can I tell the Page_Load event what image to show. I
think about using a paramter. But my problem is that I don't know how to add
such a parameter. Maybe it could be passed in the EventArgs argument.. I'm
not sure...
Instead of sending the picture ID I could send over the bytes representing
the image. But even that, I (As Far As I Know) still have to send a paramter
to the Page_Load event
Any ideas how I should pass over such a parameter?
Jeffhello Jeff
you can track the id's and do something like getImage ( id ) in the
ItemDataBound event.
on this page is a similar example, though uses a GridView instead, but
logically it's the same
http://authors.aspalliance.com/aspx...inaryWrite.aspx
newbie: Problem with CustomValidator
asp.net 2.0
I'm creating a web site where people must register to get access to
restricted area. In the CreateUserWizard control I've added a check on email
is unique (see the code below).. The problem is that this UniqueEmail method
isn't triggered when leaving the Email field or submitting the
CreateUserWizard (click on the finish button)
<asp:CustomValidator ID="valUniqueEmail" runat="server" ErrorMessage="Your
Email address is already taken" ControlToValidate="Email"
OnServerValidate="UniqueEmail"></asp:CustomValidator>
protected void UniqueEmail(object source, ServerValidateEventArgs args)
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
Debug.WriteLine("UniqueEmail");
foreach (MembershipUser user in allUsers)
{
if (user.Email == args.Value)
{
Debug.WriteLine("Testing " + user.UserName + " against " +
args.Value);
args.IsValid = false;
}
}
}
Any suggestions?
JeffHi Jeff,
Few things:
1. If EnableClientValidation is set to false, when you leav the control,
validation is not preformed (value is only validated when page is posted
back). In addition to that, CustomValidator control exposes ValidateEmptyText
property, which should be set to true if you expect empty text is considered
as a valid value for validation.
2. Because you're utilizing event wire up, make sure AutoEventWireup is set
to true in <@.Page directive
3. Any chances submit button has CausesValidation property set to false?
Hope it helps
Milosz
"Jeff" wrote:
Quote:
Originally Posted by
Hey
>
asp.net 2.0
>
I'm creating a web site where people must register to get access to
restricted area. In the CreateUserWizard control I've added a check on email
is unique (see the code below).. The problem is that this UniqueEmail method
isn't triggered when leaving the Email field or submitting the
CreateUserWizard (click on the finish button)
>
<asp:CustomValidator ID="valUniqueEmail" runat="server" ErrorMessage="Your
Email address is already taken" ControlToValidate="Email"
OnServerValidate="UniqueEmail"></asp:CustomValidator>
>
protected void UniqueEmail(object source, ServerValidateEventArgs args)
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
Debug.WriteLine("UniqueEmail");
foreach (MembershipUser user in allUsers)
{
if (user.Email == args.Value)
{
Debug.WriteLine("Testing " + user.UserName + " against " +
args.Value);
args.IsValid = false;
}
}
}
>
Any suggestions?
>
Jeff
>
>
>
Thank you!
I've just manage to solve it. The markup of the CustomValidator was missing:
ValidationGroup="CreateUserWizard1"
Jeff
"Milosz Skalecki [MCAD]" <mily242@.DONTLIKESPAMwp.plwrote in message
news:504C4D4E-323A-460A-90AE-1A4CDEAD8237@.microsoft.com...
Quote:
Originally Posted by
Hi Jeff,
>
Few things:
>
1. If EnableClientValidation is set to false, when you leav the control,
validation is not preformed (value is only validated when page is posted
back). In addition to that, CustomValidator control exposes
ValidateEmptyText
property, which should be set to true if you expect empty text is
considered
as a valid value for validation.
>
2. Because you're utilizing event wire up, make sure AutoEventWireup is
set
to true in <@.Page directive
>
3. Any chances submit button has CausesValidation property set to false?
>
Hope it helps
>
Milosz
>
"Jeff" wrote:
>
Quote:
Originally Posted by
>Hey
>>
>asp.net 2.0
>>
>I'm creating a web site where people must register to get access to
>restricted area. In the CreateUserWizard control I've added a check on
>email
>is unique (see the code below).. The problem is that this UniqueEmail
>method
>isn't triggered when leaving the Email field or submitting the
>CreateUserWizard (click on the finish button)
>>
><asp:CustomValidator ID="valUniqueEmail" runat="server"
>ErrorMessage="Your
>Email address is already taken" ControlToValidate="Email"
>OnServerValidate="UniqueEmail"></asp:CustomValidator>
>>
>protected void UniqueEmail(object source, ServerValidateEventArgs args)
>{
> MembershipUserCollection allUsers = Membership.GetAllUsers();
> Debug.WriteLine("UniqueEmail");
> foreach (MembershipUser user in allUsers)
> {
> if (user.Email == args.Value)
> {
> Debug.WriteLine("Testing " + user.UserName + " against " +
>args.Value);
> args.IsValid = false;
> }
> }
>}
>>
>Any suggestions?
>>
>Jeff
>>
>>
>>
NEWBIE: problem populating a GridView
I have a GridView control in my webpage. In this GridView's
gridUsers_RowDataBound am I having problem populating the controls with info
from the datasource -
This code is the problem:
MembershipUser user = (MembershipUser)e.Row.DataItem;
The user object doesn't get a MembershipUser value, it gets the value NULL.
Here are some of the code from my webpage so can get an overview of what I'm
doing:
<asp:GridView ID="gridUsers"
runat="server"
AutoGenerateColumns="false"
OnRowDataBound="gridUsers_RowDataBound" >
protected void Page_Load(object sender, EventArgs e)
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
gridUsers.DataSource = allUsers;
gridUsers.DataBind();
}
protected void gridUsers_RowDataBound(object o, GridViewRowEventArgs e)
{
MembershipUser user = (MembershipUser)e.Row.DataItem; **** < this code
don't work
ProfileCommon userProfile = Profile.GetProfile(user.UserName);
/*
Here I will put code that manually populate the columns in the
GridView with info from the Profile object
*/
}
any suggestions on what I should do to populate the user object with the
MembershipUser value?
JeffFixed, I had forgotten this if statement:
if (e.Row.RowType == DataControlRowType.DataRow)
"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:eXxSBdzWHHA.4860@.TK2MSFTNGP04.phx.gbl...
> ASP.NET 2.0
> I have a GridView control in my webpage. In this GridView's
> gridUsers_RowDataBound am I having problem populating the controls with
> info from the datasource -
> This code is the problem:
> MembershipUser user = (MembershipUser)e.Row.DataItem;
> The user object doesn't get a MembershipUser value, it gets the value
> NULL.
> Here are some of the code from my webpage so can get an overview of what
> I'm doing:
> <asp:GridView ID="gridUsers"
> runat="server"
> AutoGenerateColumns="false"
> OnRowDataBound="gridUsers_RowDataBound" >
> protected void Page_Load(object sender, EventArgs e)
> {
> MembershipUserCollection allUsers = Membership.GetAllUsers();
> gridUsers.DataSource = allUsers;
> gridUsers.DataBind();
> }
> protected void gridUsers_RowDataBound(object o, GridViewRowEventArgs e)
> {
> MembershipUser user = (MembershipUser)e.Row.DataItem; **** < this code
> don't work
> ProfileCommon userProfile = Profile.GetProfile(user.UserName);
> /*
> Here I will put code that manually populate the columns in the
> GridView with info from the Profile object
> */
> }
> any suggestions on what I should do to populate the user object with the
> MembershipUser value?
> Jeff
>
NEWBIE: problem populating a GridView
I have a GridView control in my webpage. In this GridView's
gridUsers_RowDataBound am I having problem populating the controls with info
from the datasource -
This code is the problem:
MembershipUser user = (MembershipUser)e.Row.DataItem;
The user object doesn't get a MembershipUser value, it gets the value NULL.
Here are some of the code from my webpage so can get an overview of what I'm
doing:
<asp:GridView ID="gridUsers"
runat="server"
AutoGenerateColumns="false"
OnRowDataBound="gridUsers_RowDataBound" >
protected void Page_Load(object sender, EventArgs e)
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
gridUsers.DataSource = allUsers;
gridUsers.DataBind();
}
protected void gridUsers_RowDataBound(object o, GridViewRowEventArgs e)
{
MembershipUser user = (MembershipUser)e.Row.DataItem; **** < this code
don't work
ProfileCommon userProfile = Profile.GetProfile(user.UserName);
/*
Here I will put code that manually populate the columns in the
GridView with info from the Profile object
*/
}
any suggestions on what I should do to populate the user object with the
MembershipUser value?
JeffFixed, I had forgotten this if statement:
if (e.Row.RowType == DataControlRowType.DataRow)
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:eXxSBdzWHHA.4860@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
ASP.NET 2.0
>
I have a GridView control in my webpage. In this GridView's
gridUsers_RowDataBound am I having problem populating the controls with
info from the datasource -
>
This code is the problem:
MembershipUser user = (MembershipUser)e.Row.DataItem;
The user object doesn't get a MembershipUser value, it gets the value
NULL.
>
Here are some of the code from my webpage so can get an overview of what
I'm doing:
<asp:GridView ID="gridUsers"
runat="server"
AutoGenerateColumns="false"
OnRowDataBound="gridUsers_RowDataBound" >
>
protected void Page_Load(object sender, EventArgs e)
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
gridUsers.DataSource = allUsers;
gridUsers.DataBind();
}
>
protected void gridUsers_RowDataBound(object o, GridViewRowEventArgs e)
{
MembershipUser user = (MembershipUser)e.Row.DataItem; **** < this code
don't work
ProfileCommon userProfile = Profile.GetProfile(user.UserName);
/*
Here I will put code that manually populate the columns in the
GridView with info from the Profile object
*/
}
>
any suggestions on what I should do to populate the user object with the
MembershipUser value?
>
Jeff
>
newbie: problem with Panel Height!
asp.net 2.0
I have a Panel on my webpage. Within this Panel is a Label control which
displays text over several rows...
I just tested this and when running the webpage with a lot of data in the
label control -The label control writes pass the Panel control.
I want the Panel to extend it's height automically if the height of it's
content is higher than the Panel orginally can display.
Here are some of my settigns for the Panel control;
ID="Panel1" runat="server" Height="100%"
I also tryed using Height="500px"; without any luck
Any suggestions to this?Hi Jeff.
The panel control renders as a div element on the HTML page. Consequently,
assigning the height attribute isn't going to impact the display.
For better control, you might want to nest the label control inside a table.
You can use the table to better manage the presentation. You could also
attach a CSS class to the panel -- in fact, that's probably the cleanest
solution.
When I first got started using ASP.NET, I used the label control everywhere.
As you get more comfortable with the built-in controls, you'll likely want to
gravitate toward a GridView for presentation of database fields or one of the
other controls that is better suited for this amount of data.
Good luck.
-Brenden
"Jeff" wrote:
Quote:
Originally Posted by
hey
>
asp.net 2.0
>
I have a Panel on my webpage. Within this Panel is a Label control which
displays text over several rows...
I just tested this and when running the webpage with a lot of data in the
label control -The label control writes pass the Panel control.
>
I want the Panel to extend it's height automically if the height of it's
content is higher than the Panel orginally can display.
>
Here are some of my settigns for the Panel control;
ID="Panel1" runat="server" Height="100%"
I also tryed using Height="500px"; without any luck
>
Any suggestions to this?
>
>
>
I agree and have one thing to add for newbies.
Often people want to use a panel becuase its border defaults to a nice thin
border while a table is not as slick at default.
However the following makes a nice thin border
<table width="100%" style="border: 1px solid; border-color:DarkBlue"
border="0" cellpadding="0" cellspacing="0" >
"Brenden Bixler" wrote:
Quote:
Originally Posted by
Hi Jeff.
>
The panel control renders as a div element on the HTML page. Consequently,
assigning the height attribute isn't going to impact the display.
>
For better control, you might want to nest the label control inside a table.
You can use the table to better manage the presentation. You could also
attach a CSS class to the panel -- in fact, that's probably the cleanest
solution.
>
When I first got started using ASP.NET, I used the label control everywhere.
As you get more comfortable with the built-in controls, you'll likely want to
gravitate toward a GridView for presentation of database fields or one of the
other controls that is better suited for this amount of data.
>
Good luck.
>
-Brenden
>
"Jeff" wrote:
>
Quote:
Originally Posted by
hey
asp.net 2.0
I have a Panel on my webpage. Within this Panel is a Label control which
displays text over several rows...
I just tested this and when running the webpage with a lot of data in the
label control -The label control writes pass the Panel control.
I want the Panel to extend it's height automically if the height of it's
content is higher than the Panel orginally can display.
Here are some of my settigns for the Panel control;
ID="Panel1" runat="server" Height="100%"
I also tryed using Height="500px"; without any luck
Any suggestions to this?
Thanks, I'm trying your CSS suggestion:
However I got some problems getting this to work, "height:100%" isn't
working. The text still writes pass the Panel control.
Here are more info
..profile_info
{
height:100%;
background-color:Green;
color:Red;
}
(I use green and red colors to test if the page actually reads the CSS
styles, and Yes the green and red color works. But the height have no
effect...)
Part of MasterPage.master
<asp:Panel ID="Panel1" runat="server" Style="z-index: 100; left: 165px;
position: absolute; top: 107px" Width="602px" CssClass="profile_info">
<asp:ContentPlaceHolder ID="content" runat="server">
</asp:ContentPlaceHolder>
</asp:Panel>
Part of Default.aspx:
<asp:Label ID="lblInfo" runat="server" Height="14px" Style="z-index: 107;
left: 5px;
position: absolute; top: 232px" Width="589px"></asp:Label>
The ContentPlaceHolder and the Panel is placed on a master page. And
Default.aspx are using this master page. The Label control is on the
Default.aspx file
I would prefer to use CSS instead of table....
Any suggestions?
jeff
"Brenden Bixler" <BrendenBixler@.discussions.microsoft.comwrote in message
news:55887EF0-3A6E-4446-8FCD-D1765F332A11@.microsoft.com...
Quote:
Originally Posted by
Hi Jeff.
>
The panel control renders as a div element on the HTML page. Consequently,
assigning the height attribute isn't going to impact the display.
>
For better control, you might want to nest the label control inside a
table.
You can use the table to better manage the presentation. You could also
attach a CSS class to the panel -- in fact, that's probably the cleanest
solution.
>
When I first got started using ASP.NET, I used the label control
everywhere.
As you get more comfortable with the built-in controls, you'll likely want
to
gravitate toward a GridView for presentation of database fields or one of
the
other controls that is better suited for this amount of data.
>
Good luck.
>
-Brenden
>
"Jeff" wrote:
>
Quote:
Originally Posted by
>hey
>>
>asp.net 2.0
>>
>I have a Panel on my webpage. Within this Panel is a Label control which
>displays text over several rows...
>I just tested this and when running the webpage with a lot of data in the
>label control -The label control writes pass the Panel control.
>>
>I want the Panel to extend it's height automically if the height of it's
>content is higher than the Panel orginally can display.
>>
>Here are some of my settigns for the Panel control;
>ID="Panel1" runat="server" Height="100%"
>I also tryed using Height="500px"; without any luck
>>
>Any suggestions to this?
>>
>>
>>
If i understand what you want correctly if you want a panel to grow and
shrink given the amount of information you have you are better off not using
a panel at all but rather a table.
Second thing to keep in the back of your mind most controls have issues with
Height=100%. The reason for this is becuase in theory a web browser has an
infinite height becuase it has a scroll bar so the controls basically wonder
"how far is 100% anyway?"
In short, for autogrow/shrink solutions the best solutions are div's and
tables.
Now if you need server side control over your tables you can do that however
that is a different subject.
"Jeff" wrote:
Quote:
Originally Posted by
Thanks, I'm trying your CSS suggestion:
>
However I got some problems getting this to work, "height:100%" isn't
working. The text still writes pass the Panel control.
>
Here are more info
..profile_info
{
height:100%;
background-color:Green;
color:Red;
}
(I use green and red colors to test if the page actually reads the CSS
styles, and Yes the green and red color works. But the height have no
effect...)
>
Part of MasterPage.master
<asp:Panel ID="Panel1" runat="server" Style="z-index: 100; left: 165px;
position: absolute; top: 107px" Width="602px" CssClass="profile_info">
<asp:ContentPlaceHolder ID="content" runat="server">
</asp:ContentPlaceHolder>
</asp:Panel>
>
Part of Default.aspx:
<asp:Label ID="lblInfo" runat="server" Height="14px" Style="z-index: 107;
left: 5px;
position: absolute; top: 232px" Width="589px"></asp:Label>
>
>
The ContentPlaceHolder and the Panel is placed on a master page. And
Default.aspx are using this master page. The Label control is on the
Default.aspx file
>
I would prefer to use CSS instead of table....
>
Any suggestions?
>
jeff
>
>
>
"Brenden Bixler" <BrendenBixler@.discussions.microsoft.comwrote in message
news:55887EF0-3A6E-4446-8FCD-D1765F332A11@.microsoft.com...
Quote:
Originally Posted by
Hi Jeff.
The panel control renders as a div element on the HTML page. Consequently,
assigning the height attribute isn't going to impact the display.
For better control, you might want to nest the label control inside a
table.
You can use the table to better manage the presentation. You could also
attach a CSS class to the panel -- in fact, that's probably the cleanest
solution.
When I first got started using ASP.NET, I used the label control
everywhere.
As you get more comfortable with the built-in controls, you'll likely want
to
gravitate toward a GridView for presentation of database fields or one of
the
other controls that is better suited for this amount of data.
Good luck.
-Brenden
"Jeff" wrote:
Quote:
Originally Posted by
hey
>
asp.net 2.0
>
I have a Panel on my webpage. Within this Panel is a Label control which
displays text over several rows...
I just tested this and when running the webpage with a lot of data in the
label control -The label control writes pass the Panel control.
>
I want the Panel to extend it's height automically if the height of it's
content is higher than the Panel orginally can display.
>
Here are some of my settigns for the Panel control;
ID="Panel1" runat="server" Height="100%"
I also tryed using Height="500px"; without any luck
>
Any suggestions to this?
>
>
>
>
>
>
newbie: Problem with CustomValidator
asp.net 2.0
I'm creating a web site where people must register to get access to
restricted area. In the CreateUserWizard control I've added a check on email
is unique (see the code below).. The problem is that this UniqueEmail method
isn't triggered when leaving the Email field or submitting the
CreateUserWizard (click on the finish button)
<asp:CustomValidator ID="valUniqueEmail" runat="server" ErrorMessage="Your
Email address is already taken" ControlToValidate="Email"
OnServerValidate="UniqueEmail"></asp:CustomValidator>
protected void UniqueEmail(object source, ServerValidateEventArgs args)
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
Debug.WriteLine("UniqueEmail");
foreach (MembershipUser user in allUsers)
{
if (user.Email == args.Value)
{
Debug.WriteLine("Testing " + user.UserName + " against " +
args.Value);
args.IsValid = false;
}
}
}
Any suggestions?
JeffHi Jeff,
Few things:
1. If EnableClientValidation is set to false, when you leav the control,
validation is not preformed (value is only validated when page is posted
back). In addition to that, CustomValidator control exposes ValidateEmptyTex
t
property, which should be set to true if you expect empty text is considered
as a valid value for validation.
2. Because you're utilizing event wire up, make sure AutoEventWireup is set
to true in <@.Page > directive
3. Any chances submit button has CausesValidation property set to false?
Hope it helps
Milosz
"Jeff" wrote:
> Hey
> asp.net 2.0
> I'm creating a web site where people must register to get access to
> restricted area. In the CreateUserWizard control I've added a check on ema
il
> is unique (see the code below).. The problem is that this UniqueEmail meth
od
> isn't triggered when leaving the Email field or submitting the
> CreateUserWizard (click on the finish button)
> <asp:CustomValidator ID="valUniqueEmail" runat="server" ErrorMessage="Your
> Email address is already taken" ControlToValidate="Email"
> OnServerValidate="UniqueEmail"></asp:CustomValidator>
> protected void UniqueEmail(object source, ServerValidateEventArgs args)
> {
> MembershipUserCollection allUsers = Membership.GetAllUsers();
> Debug.WriteLine("UniqueEmail");
> foreach (MembershipUser user in allUsers)
> {
> if (user.Email == args.Value)
> {
> Debug.WriteLine("Testing " + user.UserName + " against " +
> args.Value);
> args.IsValid = false;
> }
> }
> }
> Any suggestions?
> Jeff
>
>
Thank you!
I've just manage to solve it. The markup of the CustomValidator was missing:
ValidationGroup="CreateUserWizard1"
Jeff
"Milosz Skalecki [MCAD]" <mily242@.DONTLIKESPAMwp.pl> wrote in message
news:504C4D4E-323A-460A-90AE-1A4CDEAD8237@.microsoft.com...
> Hi Jeff,
> Few things:
> 1. If EnableClientValidation is set to false, when you leav the control,
> validation is not preformed (value is only validated when page is posted
> back). In addition to that, CustomValidator control exposes
> ValidateEmptyText
> property, which should be set to true if you expect empty text is
> considered
> as a valid value for validation.
> 2. Because you're utilizing event wire up, make sure AutoEventWireup is
> set
> to true in <@.Page > directive
> 3. Any chances submit button has CausesValidation property set to false?
> Hope it helps
> Milosz
> "Jeff" wrote:
>
Saturday, March 24, 2012
newbie: repeater problem
asp.net 2.0
I have a web page with a repeater control... In the ItemTemplate of the
repeater control have I placed a ImageMap. So every row in the repeater
control has a ImageMap. (it's the same ImageMap, but it's repeated to every
line in the repeater control)
A ImageMap has a "click" event. How can the click event know which ImageMap
in the repeater control has been clicked? I need to know this, because I
want to retrieve some data from that row and embedd it into a querystring
Any suggestions?
JeffJeff,
First parameter passed to the event handler is the source of the event. You
can set a breakpoint inside the handler and watch what is being passed
there.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:eqWqOkSsGHA.4472@.TK2MSFTNGP02.phx.gbl...
Quote:
Originally Posted by
hey
>
asp.net 2.0
>
I have a web page with a repeater control... In the ItemTemplate of the
repeater control have I placed a ImageMap. So every row in the repeater
control has a ImageMap. (it's the same ImageMap, but it's repeated to
every line in the repeater control)
>
A ImageMap has a "click" event. How can the click event know which
ImageMap in the repeater control has been clicked? I need to know this,
because I want to retrieve some data from that row and embedd it into a
querystring
>
Any suggestions?
>
Jeff
>
Newbie: storing static data within a custom control
I am an experienced Web programmer, now learning ASP.net 2.0. I am
currently teaching myself how to create a custom control. I have the
control designed and it renders beautifully. The only problem I have
is that I would like to store some static data in this control. The
control is an address control and it has a dropdown for the state.
Since state names are static, it seems to me to be best practice to
store the names within the control. So, question #1 is: Is that truly
best practice?
If it is best practice, question #2a: Is there any advantage to storing
the data as an array and having the control loop as it renders versus
hardcoding all the renders for the <option> tags?
If it is NOT best practice, question #2b: What is the recommended
alternative?
As always, any ideas, resources, references, war stories, or good clean
jokes would be greatly appreciated.
Thanks,
KathrynHard-coding the states into the HTML is a perfectly acceptible way to do it.
Its only 100 characters, anyhow (not including tags).
Best practices would dictate that this is bad, because it is not localizable
(globalizable? Ironic that you make something globally accessible by making
it localizable). But if your web app isn't designed from the start to be
localizable, who cares? It takes a tremendous amount of effort to
internationalize your application; but if that isn't in the scope of the app
,
then stick it in the HTML and be happy you don't have to learn how they do
mailing addresses in Zimbabwe.
"kbutterly" wrote:
> Good morning all,
> I am an experienced Web programmer, now learning ASP.net 2.0. I am
> currently teaching myself how to create a custom control. I have the
> control designed and it renders beautifully. The only problem I have
> is that I would like to store some static data in this control. The
> control is an address control and it has a dropdown for the state.
> Since state names are static, it seems to me to be best practice to
> store the names within the control. So, question #1 is: Is that truly
> best practice?
> If it is best practice, question #2a: Is there any advantage to storing
> the data as an array and having the control loop as it renders versus
> hardcoding all the renders for the <option> tags?
> If it is NOT best practice, question #2b: What is the recommended
> alternative?
> As always, any ideas, resources, references, war stories, or good clean
> jokes would be greatly appreciated.
> Thanks,
> Kathryn
Newbie: storing static data within a custom control
I am an experienced Web programmer, now learning ASP.net 2.0. I am
currently teaching myself how to create a custom control. I have the
control designed and it renders beautifully. The only problem I have
is that I would like to store some static data in this control. The
control is an address control and it has a dropdown for the state.
Since state names are static, it seems to me to be best practice to
store the names within the control. So, question #1 is: Is that truly
best practice?
If it is best practice, question #2a: Is there any advantage to storing
the data as an array and having the control loop as it renders versus
hardcoding all the renders for the <optiontags?
If it is NOT best practice, question #2b: What is the recommended
alternative?
As always, any ideas, resources, references, war stories, or good clean
jokes would be greatly appreciated.
Thanks,
KathrynWilliam,
Thanks, that makes sense.
Have a good week,
Kathryn
William Sullivan wrote:
Quote:
Originally Posted by
Hard-coding the states into the HTML is a perfectly acceptible way to do it.
Its only 100 characters, anyhow (not including tags).
>
Best practices would dictate that this is bad, because it is not localizable
(globalizable? Ironic that you make something globally accessible by making
it localizable). But if your web app isn't designed from the start to be
localizable, who cares? It takes a tremendous amount of effort to
internationalize your application; but if that isn't in the scope of the app,
then stick it in the HTML and be happy you don't have to learn how they do
mailing addresses in Zimbabwe.
>
"kbutterly" wrote:
>
Quote:
Originally Posted by
Good morning all,
I am an experienced Web programmer, now learning ASP.net 2.0. I am
currently teaching myself how to create a custom control. I have the
control designed and it renders beautifully. The only problem I have
is that I would like to store some static data in this control. The
control is an address control and it has a dropdown for the state.
Since state names are static, it seems to me to be best practice to
store the names within the control. So, question #1 is: Is that truly
best practice?
If it is best practice, question #2a: Is there any advantage to storing
the data as an array and having the control loop as it renders versus
hardcoding all the renders for the <optiontags?
If it is NOT best practice, question #2b: What is the recommended
alternative?
As always, any ideas, resources, references, war stories, or good clean
jokes would be greatly appreciated.
Thanks,
Kathryn
Newbie: switch control
switch value with button in the page (below failig test code).
I know in this test case I could create an extra variable and use it, my
problem is the switch, i my real problem is in a repeater, hence I cannot
use a property!
how to change the label of the galador:Switch?
--
<script runat="server">
void OnSwapSwitch(object sender, EventArgs e)
{
switch (mySwitch.Value)
{
case "0":
mySwitch.Value = "1";
break;
default:
mySwitch.Value = "0";
break;
}
}
</script>
<galador:Switch id=mySwitch runat=server Value=1 >
<galador:SwitchCase runat=server label=0>
Azerty
<asp:LinkButton ID="LinkButton1" Runat=server
OnClick=OnSwapSwitch >Clic
Clac</asp:LinkButton>
</galador:SwitchCase>
<galador:SwitchCase runat=server label=1>
Qwerty
<asp:LinkButton ID="LinkButton2" Runat=server
OnClick=OnSwapSwitch >Kodak</asp:LinkButton>
</galador:SwitchCase>
</galador:Switch>Have you tried to databind your value to some variable? For example, when
you switch, in your back-end code, if you set some variable ( string MyVar =
"";), then do a Page.DataBind(), then you can access it in your ascx/aspx
code using something like this... <galador:SwitchCase runat=server
label="<%= MyVar %>">
Would that work for you?
Alex
"Lloyd Dupont" <ld@.NewsAccount.galador.net> wrote in message
news:uxC$yS%23wEHA.3416@.TK2MSFTNGP09.phx.gbl...
> I try to create a switch control, but I'm hitting a problem, changing the
> switch value with button in the page (below failig test code).
> I know in this test case I could create an extra variable and use it, my
> problem is the switch, i my real problem is in a repeater, hence I cannot
> use a property!
> how to change the label of the galador:Switch?
> --
> <script runat="server">
> void OnSwapSwitch(object sender, EventArgs e)
> {
> switch (mySwitch.Value)
> {
> case "0":
> mySwitch.Value = "1";
> break;
> default:
> mySwitch.Value = "0";
> break;
> }
> }
> </script>
> <galador:Switch id=mySwitch runat=server Value=1 >
> <galador:SwitchCase runat=server label=0>
> Azerty
> <asp:LinkButton ID="LinkButton1" Runat=server
> OnClick=OnSwapSwitch >Clic
> Clac</asp:LinkButton>
> </galador:SwitchCase>
> <galador:SwitchCase runat=server label=1>
> Qwerty
> <asp:LinkButton ID="LinkButton2" Runat=server
> OnClick=OnSwapSwitch >Kodak</asp:LinkButton>
> </galador:SwitchCase>
> </galador:Switch>
>
well, I guess I will have too...
but what I wonder is, my switch is in a repeater, how could I store the
value in a variable?
"Alex" <Alex@.donotemailme.com> wrote in message
news:uE1nVCGxEHA.1984@.TK2MSFTNGP14.phx.gbl...
> Have you tried to databind your value to some variable? For example, when
> you switch, in your back-end code, if you set some variable ( string MyVar
> =
> "";), then do a Page.DataBind(), then you can access it in your ascx/aspx
> code using something like this... <galador:SwitchCase runat=server
> label="<%= MyVar %>">
> Would that work for you?
> --
> Alex
> "Lloyd Dupont" <ld@.NewsAccount.galador.net> wrote in message
> news:uxC$yS%23wEHA.3416@.TK2MSFTNGP09.phx.gbl...
>
Newbie: switch control
switch value with button in the page (below failig test code).
I know in this test case I could create an extra variable and use it, my
problem is the switch, i my real problem is in a repeater, hence I cannot
use a property!
how to change the label of the galador:Switch?
----------
<script runat="server">
void OnSwapSwitch(object sender, EventArgs e)
{
switch (mySwitch.Value)
{
case "0":
mySwitch.Value = "1";
break;
default:
mySwitch.Value = "0";
break;
}
}
</script
<galador:Switch id=mySwitch runat=server Value=1
<galador:SwitchCase runat=server label=0>
Azerty
<asp:LinkButton ID="LinkButton1" Runat=server
OnClick=OnSwapSwitch >Clic
Clac</asp:LinkButton>
</galador:SwitchCase
<galador:SwitchCase runat=server label=1>
Qwerty
<asp:LinkButton ID="LinkButton2" Runat=server
OnClick=OnSwapSwitch >Kodak</asp:LinkButton>
</galador:SwitchCase
</galador:SwitchHave you tried to databind your value to some variable? For example, when
you switch, in your back-end code, if you set some variable ( string MyVar =
"";), then do a Page.DataBind(), then you can access it in your ascx/aspx
code using something like this... <galador:SwitchCase runat=server
label="<%= MyVar %>"
Would that work for you?
--
Alex
"Lloyd Dupont" <ld@.NewsAccount.galador.net> wrote in message
news:uxC$yS%23wEHA.3416@.TK2MSFTNGP09.phx.gbl...
> I try to create a switch control, but I'm hitting a problem, changing the
> switch value with button in the page (below failig test code).
> I know in this test case I could create an extra variable and use it, my
> problem is the switch, i my real problem is in a repeater, hence I cannot
> use a property!
> how to change the label of the galador:Switch?
> ----------
> <script runat="server">
> void OnSwapSwitch(object sender, EventArgs e)
> {
> switch (mySwitch.Value)
> {
> case "0":
> mySwitch.Value = "1";
> break;
> default:
> mySwitch.Value = "0";
> break;
> }
> }
> </script>
> <galador:Switch id=mySwitch runat=server Value=1 >
> <galador:SwitchCase runat=server label=0>
> Azerty
> <asp:LinkButton ID="LinkButton1" Runat=server
> OnClick=OnSwapSwitch >Clic
> Clac</asp:LinkButton>
> </galador:SwitchCase>
> <galador:SwitchCase runat=server label=1>
> Qwerty
> <asp:LinkButton ID="LinkButton2" Runat=server
> OnClick=OnSwapSwitch >Kodak</asp:LinkButton>
> </galador:SwitchCase>
> </galador:Switch>
well, I guess I will have too...
but what I wonder is, my switch is in a repeater, how could I store the
value in a variable?
"Alex" <Alex@.donotemailme.com> wrote in message
news:uE1nVCGxEHA.1984@.TK2MSFTNGP14.phx.gbl...
> Have you tried to databind your value to some variable? For example, when
> you switch, in your back-end code, if you set some variable ( string MyVar
> =
> "";), then do a Page.DataBind(), then you can access it in your ascx/aspx
> code using something like this... <galador:SwitchCase runat=server
> label="<%= MyVar %>">
> Would that work for you?
> --
> Alex
> "Lloyd Dupont" <ld@.NewsAccount.galador.net> wrote in message
> news:uxC$yS%23wEHA.3416@.TK2MSFTNGP09.phx.gbl...
>> I try to create a switch control, but I'm hitting a problem, changing the
>> switch value with button in the page (below failig test code).
>>
>> I know in this test case I could create an extra variable and use it, my
>> problem is the switch, i my real problem is in a repeater, hence I cannot
>> use a property!
>>
>> how to change the label of the galador:Switch?
>> ----------
>> <script runat="server">
>> void OnSwapSwitch(object sender, EventArgs e)
>> {
>> switch (mySwitch.Value)
>> {
>> case "0":
>> mySwitch.Value = "1";
>> break;
>> default:
>> mySwitch.Value = "0";
>> break;
>> }
>> }
>> </script>
>>
>> <galador:Switch id=mySwitch runat=server Value=1 >
>>
>> <galador:SwitchCase runat=server label=0>
>> Azerty
>> <asp:LinkButton ID="LinkButton1" Runat=server
>> OnClick=OnSwapSwitch >Clic
>> Clac</asp:LinkButton>
>> </galador:SwitchCase>
>>
>> <galador:SwitchCase runat=server label=1>
>> Qwerty
>> <asp:LinkButton ID="LinkButton2" Runat=server
>> OnClick=OnSwapSwitch >Kodak</asp:LinkButton>
>> </galador:SwitchCase>
>>
>> </galador:Switch>
>>
>>
newbie: user control question
Currently I have some asp.net pages that nearly implement the same
functionality - so I would like to combine them into one user control. My
question is: is it possible to pass parameters to the user control's
constructor? I would like to specify a parameter that tells the control what
to do internally (e.g. if param=1 then display textbox else display
dropdownbox). The parameter should be stored in ViewState. I could implement
public properties on the control, but I want the parameters to be set only
once.
Thanks
MarkusUser Control Constructors are not instantiated directly. Instead, you use
LoadControl() to load the UserControl. Therefore, I think going with
properties is your best bet.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Markus" <markus_nospam_stehle@.web.de> wrote in message
news:eZUT9au2DHA.3468@.TK2MSFTNGP11.phx.gbl...
> Hi all!
> Currently I have some asp.net pages that nearly implement the same
> functionality - so I would like to combine them into one user control. My
> question is: is it possible to pass parameters to the user control's
> constructor? I would like to specify a parameter that tells the control
what
> to do internally (e.g. if param=1 then display textbox else display
> dropdownbox). The parameter should be stored in ViewState. I could
implement
> public properties on the control, but I want the parameters to be set only
> once.
>
> Thanks
> Markus
Friday, March 16, 2012
Newline detected when add script in C# (ASP.NET)
I'm trying to add script to the page and place following code in my ascx
(control):
Page.RegisterClientScriptBlock("adder", "<script>function
doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
eval(document.all.TextBox2.value)}</script>");
It doesn't work giving me all kind of problems...
I suspect the problem is with <> charachters.
How do I go around this problem?
Also, placing this line in code (I use WebMatrix) will mess up all HTML
code??
Thanks!If that is the exact line from your code, then it just has to do with how
your formed your string. You cannot insert a line break in a string in C#.
It should work if you change your code to read:
Page.RegisterClientScriptBlock("adder", "<script>function " +
"doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
" +
"eval(document.all.TextBox2.value)}</script>");
or, for more readability, I always for my javascript in a temp variable
first. Just kinda hard to read otherwise
string script = "<script>function " +
"doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
" +
"eval(document.all.TextBox2.value)}</script>"
Page.RegisterClientScriptBlock("adder", script);
either way, both of those should work for you.
-Cliff
"Ivan Demkovitch" <i@.a.b> wrote in message
news:OfydJF8oDHA.976@.tk2msftngp13.phx.gbl...
> Hi!
> I'm trying to add script to the page and place following code in my ascx
> (control):
>
> Page.RegisterClientScriptBlock("adder", "<script>function
> doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
> eval(document.all.TextBox2.value)}</script>");
> It doesn't work giving me all kind of problems...
> I suspect the problem is with <> charachters.
> How do I go around this problem?
> Also, placing this line in code (I use WebMatrix) will mess up all HTML
> code??
> Thanks!
I solved problem...
Actually the problem was in "</script>"
Changed to "<" + "/" + "script>" and it works fine now.
Thanks!
"Cliff Harris" <hersh@.myrealbox.com> wrote in message
news:OkD03L8oDHA.644@.TK2MSFTNGP11.phx.gbl...
> If that is the exact line from your code, then it just has to do with how
> your formed your string. You cannot insert a line break in a string in
C#.
> It should work if you change your code to read:
> Page.RegisterClientScriptBlock("adder", "<script>function " +
> "doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value)
+
> " +
> "eval(document.all.TextBox2.value)}</script>");
> or, for more readability, I always for my javascript in a temp variable
> first. Just kinda hard to read otherwise
> string script = "<script>function " +
> "doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value)
+
> " +
> "eval(document.all.TextBox2.value)}</script>"
> Page.RegisterClientScriptBlock("adder", script);
> either way, both of those should work for you.
> -Cliff
>
> "Ivan Demkovitch" <i@.a.b> wrote in message
> news:OfydJF8oDHA.976@.tk2msftngp13.phx.gbl...
> > Hi!
> > I'm trying to add script to the page and place following code in my ascx
> > (control):
> > Page.RegisterClientScriptBlock("adder", "<script>function
> > doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
> > eval(document.all.TextBox2.value)}</script>");
> > It doesn't work giving me all kind of problems...
> > I suspect the problem is with <> charachters.
> > How do I go around this problem?
> > Also, placing this line in code (I use WebMatrix) will mess up all HTML
> > code??
> > Thanks!