|
Ask this girl[^] for the sample code.
|
|
|
|
|
Hi,
I have an aspx page which refers to a master page. In the child page, I have to refer and retrieve the text of a server side textbox of the same page.And this text should be displayed in the browser's status bar.To display the text in status bar, I can use window.status in javascript. But, how can we access that server control's value from script??
Any suggstions....Please welcome....Thanq
-Priya
|
|
|
|
|
I usually solve this by typing out the value from the server control to the page to a javascript variable that i can use by the script later. Typically:
myLiteral.Text = ""
myLiteral.Text += "var myVar=" + theValue;
myLiteral.Text += ""
Controls.Add(myLiteral)
Then use the variable myVar on the client!
|
|
|
|
|
i keep having runtime errors everytime i try to update my database in the datalist. Can someone pls help me rectify them?
aspx. file
this is in the EditItemTemplate of the datalist control.
<br />
<EditItemTemplate><br />
<table width="100%" height="100%" cellpadding="1" border="1"><br />
<tr><br />
<td style="width: 54px"><br />
<%#DataBinder.Eval(Container.DataItem, "ID")%><br />
</td><br />
<td style="width: 300px"><br />
<%#DataBinder.Eval(Container.DataItem, "checklist_Item")%><br />
</td><br />
<td style="width: 230px"><br />
<asp:TextBox ID="txtEventDate" text='<%#DataBinder.Eval(Container.DataItem, "date_Completed")%>' runat="server"></asp:TextBox</td><br />
<td style="width: 160px"><br />
<asp:TextBox ID="txtEventTrigger" text='<%#DataBinder.Eval(Container.DataItem, "date_Trigger")%>' runat="server"></asp:TextBox><br />
</td><br />
<td style="width: 100px"><br />
<asp:Button ID="btnUpdate" CommandName="Update" Text="Update" runat="server" /></td><br />
</tr><br />
</table><br />
</EditItemTemplate><br />
aspx.vb file
Sub MyDataList_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles MyDataList.UpdateCommand<br />
Dim tbox As TextBox<br />
Dim ID As String<br />
'Dim txtEventDate, txtEventTrigger As Date<br />
'Dim ID, txtEventDate, txtEventTrigger As String<br />
Dim txtEventDate, txtEventTrigger<br />
<br />
'---retrieves the key for the row---<br />
ID = MyDataList.DataKeys(e.Item.ItemIndex)<br />
'MsgBox("1")<br />
<br />
'---find the textbox control containing the title<br />
tbox = CType(e.Item.FindControl("txtEventDate"), TextBox)<br />
txtEventDate = tbox.Text<br />
'MsgBox("2")<br />
<br />
'---find the textbox control containing the price<br />
tbox = CType(e.Item.FindControl("txtEventTrigger"), TextBox)<br />
txtEventTrigger = tbox.Text<br />
'MsgBox("3")<br />
<br />
'---updates the database---<br />
Dim sql As String = "UPDATE programs SET date_Completed='" + txtEventDate + "' , date_Trigger='" + txtEventTrigger + "' WHERE ID='" + ID + "'"<br />
Dim comm As New OleDbCommand(sql, objConn)<br />
'MsgBox("4")<br />
<br />
objConn.Open()<br />
'MsgBox("5")<br />
comm.ExecuteNonQuery()<br />
MsgBox("6")<br />
objConn.Close()<br />
<br />
MyDataList.EditItemIndex = -1<br />
'MyDataList.DataBind()<br />
LoadData()<br />
<br />
<br />
End Sub
The error as displayed:
Data type mismatch in criteria expression.
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.Data.OleDb.OleDbException: Data type mismatch in criteria expression.
Source Error:
Line 76: objConn.Open()
Line 77: 'MsgBox("5")
<code>Line 78: comm.ExecuteNonQuery()</code>
Line 79: MsgBox("6")
Line 80: objConn.Close()
Stack Trace:
[OleDbException (0x80040e07): Data type mismatch in criteria expression.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +177
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +194
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +56
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +105
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +88
Tracking.Default1.MyDataList_UpdateCommand(Object source, DataListCommandEventArgs e) in C:\Documents and Settings\username\My Documents\Visual Studio 2005\Websites\WebSite2\Default.aspx.vb:78
System.Web.UI.WebControls.DataListCommandEventHandler.Invoke(Object source, DataListCommandEventArgs e) +0
System.Web.UI.WebControls.DataList.OnUpdateCommand(DataListCommandEventArgs e) +75
System.Web.UI.WebControls.DataList.OnBubbleEvent(Object source, EventArgs e) +228
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.DataListItem.OnBubbleEvent(Object source, EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +85
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4918
frossie
|
|
|
|
|
Hi,
The Error might be [Datatype in the database must be numeric and you are assigning a string to it], If your database is ms-access use "#" for the date columns.
|
|
|
|
|
can you show me an example code to put in access or the codefile?
becos i don really get what u say.
frossie
|
|
|
|
|
You can check the query which you are generating, check that query by executing it in backend first.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi,
check this out,
(1)
"UPDATE programs SET date_Completed=#" + txtEventDate + "# , date_Trigger=#" + txtEventTrigger + "# WHERE ID='" + ID + "'"
(2)
"UPDATE programs SET date_Completed=#" + txtEventDate + "# , date_Trigger=#" + txtEventTrigger + "# WHERE ID=" + ID
for (1)
provided [date_completed is date, date_trigger is date and ID is string] in database
for (2)
provided [date_completed is date, date_trigger is date and ID is numeric] in database
display this query string in ur browser and copy paste in database, run it out and check.
|
|
|
|
|
ok thanks alot.
it finally solved that problem.
frossie
|
|
|
|
|
If (ID = 2) Then<br />
<pre>TextBox1.Text = ds.Tables("programs").Rows(ID).Item(2)</pre><br />
Dim temp1 As New DateTime(Year(TextBox1.Text), Month(TextBox1.Text), Day(TextBox1.Text))<br />
MsgBox("temp1=" + temp1)<br />
temp1 = temp1.AddDays(7)<br />
ds.Tables("programs").Rows(ID + 1).Item(3) = temp1<br />
<br />
End If
i keep getting this error "Object reference not set to an instance of an object". Why isit so?
frossie
|
|
|
|
|
Which line you get the error? Check whether that object exists or not.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Can you help me complete this ASP.NET exercise wsing Visual Studio 2003?
Your employer wants you to create a shopping cart application. First, create a database called ShoppingXXX (xxx are your initials). For this exercise you will be using Microsfoft ACCESS.
Include the name of the product, price, description, and the product ID.
Create sample data (be creative, you are suppose to be having fun).
Create a web page that displays the data using a DataGrid control.
Format the dataGrid using the Property Builder.
Add your photo, graphics, color, and content to enhance the appearance of the page.
Do all of your work in one folder (all files, database, and graphics). Everything must be in the one folder.
Can you help me with the code I need for this exercise?
Any help would be greatly appreciated.
Thank you very much!!
Kevin
|
|
|
|
|
TheKiwi wrote: Can you help me with the code I need for this exercise?
The short answer is no.
The longer answer is found here[^].
If you want to ask a specific question, or ask for help solving a specific problem you're having, I'm sure you'll find there are many folks here willing to help.
|
|
|
|
|
If you could buy only one book on building Server Controls in ASP.NET, which book would it be and why?
It seems like I spend the most project time debugging controls and tracing what's going on. I'd like to get a definitive guide to developing server controls so that I can master this and get on with the real work!
TIA for you input.
|
|
|
|
|
If you are doing the ASP.NET 1.1, my recommendation is Nikhil's book[^]. For the version 2.0, I'm not sure if he has a plan for the second edition, but Dino Esposito is the name that I respect most and you might want to check out his book[^] and his crash courses in MSDN[^].
|
|
|
|
|
I'm doing .NET 2.0 these days.
|
|
|
|
|
Any suggestions on which methodlogies we should choose? What is preffered for .NET?
How successfull are Agile and Extreme Programming in real world?
Please suggesst some books and/or online article.
Thanks.
Robert
|
|
|
|
|
I'm using a details view for the first time.
I have a data access layer in my program so I'd like to avoid using the SQLDataSource Object if I can.
I've been trying to do an insert with the details view.
On my details view I have OnItemInserting="DetailsViewSubmit_Insert"
in my code section I have a function:
protected void DetailsViewSubmit_Insert(Object sender, DetailsViewInsertEventArgs e)
From what I'm reading the information the user typed into the text boxes is supposed to be an an Idictionary object at "e.Values"
However when I check e.Values.count its always empty.
Has someone else come across this problem, or perhaps is there a better way to use the details view?
Here's the full details view.
<asp:DetailsView ID="DetailsViewSubmit" runat="server"
Height="50px" Width="125px"
DataKeyNames="FeedbackKey"
DefaultMode="Insert" AutoGenerateRows="False"
OnItemInserting="DetailsViewSubmit_Insert">
<Fields>
<asp:BoundField HeaderText="Subject" DataField="Subject">
<ControlStyle Width="600px" />
</asp:BoundField>
<asp:BoundField HeaderText="Body" DataField="Body">
<ControlStyle Height="250px" Width="600px" />
</asp:BoundField>
<asp:CommandField ShowCancelButton="False" ShowInsertButton="True"
InsertText="Submit" />
</Fields>
</asp:DetailsView>
protected void DetailsViewSubmit_Insert(Object sender, DetailsViewInsertEventArgs e)
{
Response.Write("DetailsViewSubmit called - count = " + e.Values.Count);
}
|
|
|
|
|
The e.Values is only specified when you use the DetailsView control with a datasource control, here you have a data access layer you then may consider using the ObjectDataSource with the control. If you don't specify any datasource control in the DataSourceId property of the DetailsView, you'll need to manually get values from the control and do the insert command. You can read more about how to use the ObjectDataSource and DetailsView control in MSDN.
|
|
|
|
|
thank you for your previous help from before
I've been using a detailsview, an object data sources, with a data access layer, and a stored procedure, and my back to a problem with E.values.
What i'm trying to do is, after I insert a new event, I want to get the the key of the newly inserted event and set that key as my current key for the details view.
I've been playing with the parameter output, I know that i'm setting EventsKey to the newly added record. I tried to catch it in "OnItemInserted" but when I output all the values from e.values, the new key isn't part of that list.
I don't know where the output parameter would be stored, or if there's a better way to get this new key value back to the business layer.
Drathmar
Here's my code:
**Object Data source**
<asp:ObjectDataSource
ID="ObjectDataSourceDetailsView"
runat="server"
TypeName="AspNet.StudentHealthRecords.HealthDbUtility"
SelectMethod="EventsGetByKey"
InsertMethod="EventsAdd"
UpdateMethod="EventsUpdate"
>
<SelectParameters>
<asp:Parameter Name="EventKey" Type="String" DefaultValue="-1" />
</SelectParameters>
<InsertParameters>
<asp:SessionParameter Name="UserKey" SessionField="UserKey" Type="string" />
<asp:Parameter Name="EventDate" Type="String" />
<asp:Parameter Name="EventKey" Type="string" Direction="Output" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="EventKey" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
**data access layer function**
public static Boolean EventsAdd(string UserKey, string EventTitle, string EventDescription,
DateTime EventDate, out string Eventkey)
{
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("EventsAdd", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@UserKey", SqlDbType.Int, 4));
cmd.Parameters["@UserKey"].Value = UserKey;
cmd.Parameters.Add(new SqlParameter("@EventTitle", SqlDbType.VarChar, 20));
cmd.Parameters["@EventTitle"].Value = EventTitle;
cmd.Parameters.Add(new SqlParameter("@EventDescription", SqlDbType.VarChar, 500));
cmd.Parameters["@EventDescription"].Value = EventDescription;
cmd.Parameters.Add(new SqlParameter("@EventDate", SqlDbType.DateTime, 8));
cmd.Parameters["@EventDate"].Value = EventDate.ToShortDateString();
cmd.Parameters.Add(new SqlParameter("@DtTm", SqlDbType.DateTime, 8));
cmd.Parameters["@DtTm"].Value = DateTime.Now.ToShortDateString();
try
{
con.Open();
Eventkey = cmd.ExecuteScalar().ToString();
return true;
}
catch (SqlException err)
{
// Replace the error with something less specific.
// You could also log the error now.
throw new ApplicationException("Data error.", err);
}
finally
{
con.Close();
}
return false;
}
**procedure**
CREATE PROCEDURE [dbo].[EventsAdd]
(
@EventTitle varchar(20),
@EventDescription varchar(500),
@EventDate DateTime,
@UserKey int,
@DtTm DateTime
)
AS
INSERT INTO dbo.Events
(EventTitle, EventDescription, EventDate, EventCategory, UserKey, DtTm)
VALUES (@EventTitle, @EventDescription, @EventDate, 0, @UserKey, @DtTm)
SELECT SCOPE_IDENTITY()
GO
** Page function**
protected void DetailsViewItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
for (int i = 0; i < e.Values.Count; i++)
{
Response.Write("item Interted values are - " + e.Values[i] + "<br>" );
}
}
|
|
|
|
|
I have a brain dead third party component that will only show images in it's predefined images folder or in a specific url. I want to define the images in the skin file as with any normal asp.net control, unfortunately it's converted all my urls to relative from the root of the web and not from the theme folder automatically as it normally would.
It does have an imagesfolder property I can set, but since the theme in use depends on the user's selection I don't want to have to programmatically set that, if there were some sort of predefined url to the active theme set by asp.net I could use that in the skin file for the ImagesFolder property and circumvent the problem.
-- modified at 16:35 Thursday 10th August, 2006
|
|
|
|
|
AFAIK, there's no way that you can get reference to the currently active theme and set in the skin file (while you can do in code). I may not understand all your context, but IMHO there are a couple of things you may check:
+ Do you use the root path reference ~ when you set the ImagesFolder property for the custom control?
+ Because you are creating the skin file for a specific theme, so I think you may probably know the theme name and you can hard code this name in the ImagesFolder property of the control in the skin file.
|
|
|
|
|
I´ve heard that its possible to run a web app without aspx files and just host the dlls on the web server. Anyhow, I haven´t managed to get this to work and haven´t found any info about how to do this.
Does anybody know how it´s done?
|
|
|
|
|
|
Premise: I'm new to Web Services.
I have an application that makes use of some assemblies, containing a class library.
I want to communicate with a server (through web services) which must use the data types contained in the same assemblies used by the application.
So I added a reference to those assemblies into the asp.net project and then added a web reference to the web service in the client application project.
I wrote some methods in the web service, they work (from the browser, at least), but Visual Studio generates a stub for the web service exposing different data types (same class names but different namespaces).
So, how can I share the same data types between the web service and the client, keeping them both in the client and in the server (I don't want to "move" the class library into the server because the web service is a secondary tool and the application must also work without it)?
I tried strong-naming but nothing changed.
Thanks for any help.
|
|
|
|
|