|
Dear Experts,
I have a shopping card. I want to support to my customer to change a template, change font and color.
Could you tell me some solutions to solve that problem.
If you have any references or source codes, please show me!
Thank you in advance
vtkiet05
|
|
|
|
|
Hi,
I am storing the checkboxlist items as comma seperated values in a row. My problem is during updation of those values. When i bind the values to the checkboxlist i want to display all items but only those items have to be checked which are present in the row.
For inserting i am using the followng code,
Dim sqlstr As String
Dim str As String = ""
If dbconn.State <> ConnectionState.Open Then
dbconn.Open()
End If
For Each item As ListItem In CheckBoxList1.Items
If item.Selected = True Then
If str = "" Then
str = item.Text
Else
str = str & "," & item.Text
End If
End If
Next
sqlstr = "insert into test(c1) values(@c)"
Dim comm As New SqlCommand(sqlstr, dbconn)
comm.Parameters.Add("@c", SqlDbType.Char, 10).Value = str
Try
comm.ExecuteNonQuery()
Label1.Visible = True
Label1.Text = "Success"
Catch ex As Exception
Label1.Visible = True
Label1.Text = ex.ToString
End Try
|
|
|
|
|
n_gchaitra wrote: My problem is during updation of those values.
I'm not sure what problem you are facing... Can you tell us more about the problem you are facing and what you wanna do?
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Michael, I have around 20 items in which only checked items have to stored. It is working fine. When i want to update that obviously i have to see all those twenty items. Here i want to them to compare with the items present in the table and the matching rows have to get checked.
Chaitra N
|
|
|
|
|
Is that what you want?
Listbox.DataSource = Database.GetAllItems(); <br />
Listbox.DataBind();<br />
<br />
string[] storedValues = Database.GetStoredItems().Split(",");<br />
<br />
foreach(string val in storedValues){<br />
foreach ( ListItem itm in ListBox1.Items ){<br />
if(itm.Value == val){<br />
itm.Checked = true;<br />
}<br />
}<br />
}<br />
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Michael I am afraid i did not understood what is "Database" in
Listbox.DataSource = Database.GetAllItems();
Listbox.DataBind();
string[] storedValues = Database.GetStoredItems().Split(",");
The code i am using to bind the values are as follows. This works fine. I want only matching values to get checked. Can u help me please?
Dim constr As String = ConfigurationSettings.AppSettings("conn")
Dim dbconn As New SqlConnection(constr)
Sub bind()
Dim sqlstr As String
sqlstr = "select software from list where sno='" & txtsno.text & "'"
Dim comm As New SqlCommand(sqlstr, dbconn)
Dim dr As SqlDataReader
If dbconn.State <> ConnectionState.Open Then
dbconn.Open()
End If
dr = comm.ExecuteReader
While dr.Read
CheckBoxList1.Items.Add(dr.Item(0).ToString)
End While
dr.Close()
End Sub
Chaitra N
|
|
|
|
|
Database should be a helper class that return the dataset after retrieving the data from database.
n_gchaitra wrote: I want only matching values to get checked.
What you meant is that there are the values (1,2,3) in database. There are 5 items (1,2,3,4,5) shown in ListBox. After retrieving the data (1,2,4) from database, you want the items (1,2,3) to be checked. Is it what you want?
Let's Database.GetAllItems(); will return all data (1,2,3,4,5) from database.
this method Database.GetStoredItems() will return all saved value as a comma seperated value (eg: 1,2,3)
eg:
public class Database{<br />
public static string GetStoredItems(){<br />
return str;
}<br />
public static DataSet GetAllItems()(){<br />
return ds;
}<br />
}
then, bind it to Listbox. (So, 1,2,3,4,5 will be shown in Listbox. )
<br />
Listbox.DataSource = Database.GetAllItems();<br />
Listbox.DataBind();
then, get the saved values from database. (In our case, we will get "1,2,3"). Split to string array. loop through the listbox and string array to find the match. If match found, we set itm.Checked = true;
string[] storedValues = Database.GetStoredItems().Split(",");<br />
<br />
foreach(string val in storedValues){<br />
foreach ( ListItem itm in ListBox1.Items ){<br />
if(itm.Value == val){<br />
itm.Checked = true;<br />
}<br />
}<br />
}
Is the way I understand correct?
Hopefully, you got my point...
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
i am getting "System.Data.DataRowView " error. I tried to write the function in the same class but still getting the same error.
Dim constr As String = ConfigurationSettings.AppSettings("conn")
Dim dbconn As New SqlConnection(constr)
Sub bind1()
CheckBoxList1.DataSource = GetAllItems()
CheckBoxList1.DataBind()
Dim storedValues As String() = Database.GetStoredItems().Split(",")
For Each val As String In storedValues
For Each itm As ListItem In CheckBoxList1.Items
If itm.Value = val Then
itm.Selected = True
End If
Next
Next
End Sub
Public Function GetAllItems() As DataSet
Dim ds As New DataSet()
Dim sqlstr As String = " select list from AList"
Dim comm As New SqlDataAdapter(sqlstr, dbconn)
comm.Fill(ds)
'Return those data as DataSet
Return ds
' 1,2,3,4,5
End Function
Public Function GetStoredItems() As String
'Get the data from Database
' Dim dbconn As New OleDb.OleDbConnection("provider=sqloledb;user id=sa;password=;trusted_connection=yes; initial catalog=wfphumanet;data source=localhost")
Dim ds As New DataSet()
Dim str As String = " select c1 from test where sl='" & TextBox1.text & "'"
'Return those data as comman seperated value
Return str
' 1,2,3
End Function
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
bind1()
End Sub
Chaitra N
|
|
|
|
|
n_gchaitra wrote: CheckBoxList1.DataSource = GetAllItems()
CheckBoxList1.DataBind()
Change like that ~
<br />
CheckBoxList1.DataSource = GetAllItems().Tables(0)<br />
CheckBoxList1.DataValueField = "list"<br />
CheckBoxList1.DataTextField = "list"<br />
CheckBoxList1.DataBind()
Full Code Sample
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br />
<br />
CheckBoxList1.DataSource = GetAllItems().Tables(0)<br />
CheckBoxList1.DataValueField = "Num"<br />
CheckBoxList1.DataTextField = "Num"<br />
CheckBoxList1.DataBind()<br />
<br />
Dim storedValues As String() = GetStoredItems().Split(",")<br />
For Each val As String In storedValues<br />
For Each itm As ListItem In CheckBoxList1.Items<br />
If itm.Value = val Then<br />
itm.Selected = True<br />
End If<br />
Next<br />
Next<br />
<br />
End Sub<br />
<br />
Public Function GetAllItems() As DataSet<br />
Dim ds As New DataSet()<br />
<br />
Dim dt As New DataTable()<br />
Dim dc As New DataColumn("Num")<br />
dt.Columns.Add(dc)<br />
<br />
For i As Integer = 1 To 5<br />
Dim dr As DataRow = dt.NewRow()<br />
dr(0) = i<br />
dt.Rows.Add(dr)<br />
Next<br />
<br />
ds.Tables.Add(dt)<br />
Return ds ' 1,2,3,4,5<br />
End Function<br />
<br />
Public Function GetStoredItems() As String<br />
Return "1,2,3"<br />
End Function<br />
<br />
Hope it helps..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
But Michael it returns only the values present in a table where i am storing all the values.
See i put my requirement in another way.
For the subscription of a website i enter some area of interest in checkboxes. Suppose if i want to modify them(addition or removal), i need to see all the options(area of interest) as well a which i had selected. All the values options will be present in one table and when i request the page it displays all the options and the options i had chosed previously have to be checked.
Let say i am storing all the options in a table "Options" in the column "Interest" and when i select them i will store the values in the table "Web" which has the columns "Email" And "Area_Of_Int".
Chaitra N
|
|
|
|
|
Hi,
I was wondering whether is it possible for me to remove the Master Page that was previously attached to one page in the program.
For example, when some criterias are met, I want the Master Page to off from the page so that I don not need to create another same aspx page without the Master Page.
Thanks in advance.
J Liang
|
|
|
|
|
You can, but I think it needs to be in PreInit or before:
C#:
protected override void Page_PreInit(object sender, EventArgs e)
{
this.MasterPageFile = "~/yes_my.master";
}
VB:
Protected Sub Page_PreInit(ByVal sender As Object, _
ByVal e As EventArgs) _
Handles Me.PreInit
Me.MasterPageFile = "~/yes_my.master"
End Sub
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hi u can remove ur master page ok no problem .. what u do means ,
1.remove ur masterpage reference from ur <@ page > page directive
2. add ur user control what u mentioned in master page that user control
3.add ur HTML guide reference
4.add ur html tags like hetml,head,title,and if u r using any any some script funtion..
thats all..
incase u cant do it send ur .aspx page and ur masterpage to my id.
n.nanthakumar@gmail.com
Reg
nantha
|
|
|
|
|
I think he wants to remove dynamically from Code.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
I don't think you can remove the master page but you can change the master page. So, you can two master pages in your website. Change it at Page_PreInit event.
Eg:
protected void Page_PreInit(object sender, EventArgs e)<br />
{<br />
this.MasterPageFile = "MasterPage2.master";<br />
<br />
}
Edit: I didn't see Steve's reply. I think his reply is the answer.. I forget to click "Submit" button before going lunch.
-- modified at 2:07 Thursday 16th August, 2007
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Before designing a web application using Master pages try to have two master page files:
1) Master page with Header.
2) Master page without Header.
Whenever you dont require the header part do the following code
protected void Page_PreInit(object sender, EventArgs e)
{
this.MasterPageFile = "MasterWOHeader.master";
}
The Idea behind this is, normally we use to include the common javascript functions in the master page since its a generic container. If you remove the masterpage then it might give you some problem[Since masterpage holds the generic javascript code], its better to embed the common javascript files in both the masterpages and use it in the required scenario.
Thanks,
Ganesh Kumar
|
|
|
|
|
Hi,
I'm hoping I've just overlooked something obvious here and someone will be able to help, one of those things where it's pretty simple and *should* work but doesn't...
I originally had this code on a page, which worked fine:
<div id="remote-support">
<h2>Remote Support</h2>
Pin code:
<asp:TextBox Width=80px ID="TextBox1" runat="server"></asp:TextBox>
<br /><br />
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
I replaced it with the following code on the page:
<div id="remote-support">
<% Response.Output.Write(Common.RemoteSupport(ThisPage))%>
</div>
And this is in some shared code in App_Code:
Public Shared Function RemoteSupport(ByVal ReferringPage As String) As String
RemoteSupport = "<h2>Remote Support</h2>" _
& "Pin code: <asp:TextBox Width=80px ID=""TextBox1"" runat=""server""></asp:TextBox><br />" _
& "<br />" _
& "<asp:Button ID=""Button1"" runat=""server"" Text=""Button"" />"
End Function
Now, what's happening is there's no controls appearing on the page, despite the page source containing the control tags as normal.
Suspect this has something to do with me getting something fundamental wrong, but can't quite get my head round what's going on. Surely it's possible to do this one way or another, maybe just not this way...
Any help would be greatly appreciated
Thanks
Chris
|
|
|
|
|
RemoteSupport = "<h2>Remote Support</h2>" _
& "Pin code: <asp:TextBox Width=80px ID=""TextBox1"" runat=""server""></asp:TextBox><br />" _
& "<br />" _
& "<asp:Button ID=""Button1"" runat=""server"" Text=""Button"" />"
You can't do like that since asp:TextBox and asp:Button are Server-side control. The way how server-side controls work is that Web Server will generate the HTML controls and send them to the browser. So, you may write HTML control like that.. then it will work..
"<h2>Remote Support</h2>" _
& "Pin code: <input type=""text"" Width=80px ID=\"TextBox1\" /><br />" _
& "<br />" _
& "<input type=""button"" value=""value"" />"
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Awesome, that will work.
Thanks for your help
|
|
|
|
|
Hello,
VS 2005
I have created an web service project and added a MSI setup project.
I added my own custom action which is a windows exe that will allow the user to select their own virtual directory for installing the web service. This worked ok.
I remove the default installation dialog from the user interface, and have the windows exe in its place.
However, as the project installs it always installs in the default C:\intput\wwwroot\websetup1 directory.
The way my custom action works is that it will create a new virtual directory then move all the files from the default directory "C:\intpub\wwwroot\websetup1". to what the user has specified. However, this mean that the default directory still exists. So the last thing that the custom action will do is delete this directory. However, as the custom action DLL has been installed in this directory I am unable to delete it "Access Denied"
So the possible solution that I have, is it possible to stop the setup installing in the default directory and install in the user specified directory instead of copying the directory across?
Many thanks for your suggestions,
Steve
|
|
|
|
|
1/ i want to display a youtube video or other content on a specific part of the page,and when its finished, display content from another source on the same place. im not sure how and in what control i should display the contect so i can get this ability. for example, if it was only text, i would do it with a label, changing its "text" property. i need the same ability but with other types of contents, primevally <object> and <embed /> content. do i need an update panel or the content source be changed with client side javascript only ?
2/ whats the process for creating "widgets" ? in widgets i mean all those objects like youtube videos, meebo and other that can be published on webpages only by adding an "<object>" tag to the page ? articles or tutorials ?
3/ whats the keyword "Or" is doing in vb.net ? what that line means ? "x Or y Or z" in vb.net ? how do i translated it to c# ?
4/ how do i plant a vb.net code in the middle of c# code in a .cs file ? is it possible ? i think i saw somthing about it..
thats it, i hope its not to much and all the questions are clear..
-- modified at 13:42 Wednesday 15th August, 2007
|
|
|
|
|
1. <asp:placeholder runat="server" id="phSomething">
content goes here
in the codebhind we set the visibility
CODEBEHIND:
if contained within a repeater or someother control: Page.FindControl("phSomething");
otherwise just:
protected void Page_Load(object sender, EventArgs e)
{
phSomething.Visible = true;
}
protected void On_Some_Event(object sender, EventArgs e)
{
phSomething.Visible = false;
}
Something to remember, the PlaceHolder control does not remember the contents of it between postbacks. So if it is needed to retain information across post backs, you can set all data to a session variable or cookie, or host the placeholder inside an AJAX Update panel and post back Asynchrously.
2. This isn't ASP.NET particularly... However you can set the "MinMaxClose" toolbar to not visible and that should help make it more difficult. I'm not a WinForms expert
3. The process of widgets in ASP.NET (this is an ASP.NET forum) is more or less using XML web services to pass data or "consume" a webservice. I dont exactly know what all you mean here, the <object> tag dates back to HTML 3.0 or even earlier... It's more or less a Web Standard nowadays.
4. OR is a keyword that is used in conditional statements.
Let's say that we want to make an if statement:
If(Algoaddict_Posts_ASPNET_Forums OR Algoaddict_Posts_Anywhere_Forums)
Algoaddict_Answered = true
EndIf
In C#:
if(Algoaddict_Posts_ASPNET_Forums | Algoaddict_Posts_ASPNET_Forums)
{
Algoaddict_Answered = true;
}
In this case, OR returns a boolean true if either case returns true. Thus, you were answered. For more information, you can see MSDN Documentation on CONDITIONAL STATEMENTS and BOOLEAN OPERATORS.
--EDIT
Darn! You modified the questions!
4. Not really possible, no. However, you can create a vb class and call that class from inside a CS file.
|
|
|
|
|
thanx a lot !
1/ what happens if i want to set the content of the window in run time ? i cant use the approach of creating all the windows and only hiding and displaying them as you suggested. an i frame would do the work, is it still being used in asp.net 2.0 after ajax arrived with all its features ? or theres an ajax replacement ? cant this be achived with updatepanel ?
4/ about the Or - i know the original usage of it and how it can be converted to c# but in this specific case, visual studio says its an integer, and its not between boolean variant - this is the exact code:
"SetWindowLong(Me.Handle, GWL.ExStyle, m_InitialStyle Or WS_EX.Layered Or WS_EX.Transparent)"
when the last parameter should be of type "Window_Library.WindowLibrary.User32Wrappers.WS_EX()"
furthermore, i tried copying the exact code and replace "Or"s with "|" and get the following error message:
Error 1 Operator '|' cannot be applied to operands of type 'int' and 'Window_Library.WindowLibrary.User32Wrappers.WS_EX'
thanx again
|
|
|
|
|
I latebind my content all the time. That's an easy one.
protected void OnDataBind_Control_to_Show(object sender, EventArgs e)
{
SetCorrectView();
}
protected void SetCorrectView()
{
Series of if statements that check for control.txt or control.value = "" or null
}
If the control has data, show it. otherwise dont. Easy peasy.
In that case, I can see howit's being used, and the reason VS shows it as an integer, is that all three possible arguments sent to the function must be integers. So, in your case, the last argument can take any of those three specific arguments, but they must all be ints.
|
|
|
|
|
i downloaded this:
http://www.codeproject.com/csharp/winformiehost.asp
and its working on my vista home basic, but not on xp sp2. the build runs ok in visual studio but the app crashes with this errro message:
System.Security.SecurityException was unhandled
Message="Request failed."
Source="SampleEventProgram"
StackTrace:
at SampleEventProgram.Form1..ctor()
at SampleEventProgram.Form1.Main()
does anyone have a clue ?
i worked a whole day making this work in c# (i managed doing it using csharper conversion) but it doesnt work on xp wich is much more important for me...
this is the error code windows is giving
EventType : clr20r3 P1 : sampleeventprogram.exe P2 : 1.0.2784.1621
P3 : 46c3840a P4 : sampleeventprogram P5 : 1.0.2784.1621
P6 : 46c3840a P7 : 8 P8 : 0 P9 : system.security.security
thanx again
-- modified at 18:55 Wednesday 15th August, 2007
|
|
|
|
|