|
It is difficult to diagnosis the problem with this description. Can you please post the entire javascript code?
|
|
|
|
|
It could be something as simple as making sure the processing page is set to not be cached.
|
|
|
|
|
yes i fixed it by not caching the page
thanks for the help.
vijay
|
|
|
|
|
Seems simple enough....Am using C# VS2008.....just trying to pass the text value of a selected item in a listbox to a text box so it can be evaluated for an SQL statement.
string year = ListBoxYears.SelectedItem.Text;
...but it fails with the following error reported:
NULL REFERENCE EXCEPTION was unhandled by user code:
Object reference not set to an instance of an object.
I am also unable to get the "selectedindexchanged" event to work as it does in C# desktop...that is to say, for it to post a changed value to any other control when a change is made in the list box;
I have tried a number of different techniques to retrieve the string, but all to no avail. I have reset the AutopostBack both on and off...no difference. And I have tried to use all of the different properties and conversion available for a listbox that could have anything to do with a string or that might be converted to a string.....no results. Obviously, my frustration level is at 100% now.
ANY assistance would be greatly appreciated....Pat
|
|
|
|
|
The SelectedItem always null if nothing selected in the listbox. So you have to validate whether the SelectedItem is null before retrieve the value.
PDTUM wrote: I am also unable to get the "selectedindexchanged" event to work as it does in C# desktop
The SelectedIndexChanged event will fire only if you set the AutoPostBack is true.
|
|
|
|
|
Thank you for your reply...I changed the AutoPostBack to true on both controls and have tried every variation of it being on and off. The following error is reported when it runs:
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.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 445: protected void ListBoxTrans_SelectedIndexChanged(object sender, EventArgs e)
Line 446: {
Line 447: TextBoxTrans.Text = ListBoxTrans.SelectedItem.Text;
Line 448: }
Line 449:}
Any other ideas?
|
|
|
|
|
Did you debug the code? Place a break point and find out the origin of error and which object is null.
|
|
|
|
|
Are you populating your list box in the page load by any chance? If so, it could be that you're not checking if the page is posting back. You might need something like this...
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
}
}
|
|
|
|
|
YES YES YES DoctorMick....that DID it. I had the list boxes initially loading in the Page_Load event and it was being confused by the postback. I do not use ASP.NET that often and sometimes have trouble migrating from C# applications....THANK YOU very much.
I am having an issue with WEB Posting on another application, which works perfectly in the desktop browser but is also giving a NULL exception error when is is running online (losing SESSION values). I will be posting that a little later today. I hope you have a moment to give it a look....and thank you all for your responses...much appreciated...Pat
|
|
|
|
|
Yes...with the debug active, the error occurs immediately upon selection of the item in the listbox when the "SelectedIndexChanged" event fires, so selecting an item does trigger the event. It just reports a NULL value even though an item is selected. It seems simple enough and I am thoroughly confused about why.
|
|
|
|
|
We are using AjaxPro2 and have following code:
JSTextTransfer.aspx
<script language="javascript" type="text/javascript">
function Getajaxfunction()
{
var flag = TextTransfer.CallAjaxFunction("Test");
alert(flag.value);
}
</script>
JSTextTransfer.aspx.cs
public partial class TextTransfer : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(TextTransfer));
if (!IsPostBack)
{
}
Btn_Ajax.Attributes.Add("onclick", "javascripe:return Getajaxfunction();");
}
[AjaxPro.AjaxMethod]
public string CallAjaxFunction(string atr)
{
return "Test";
}
}
We get the following error:
TextTransfer is undefined.
The page is hosted on a server which has the following directory structure
/htdocs/
/htdocs/bin/AjaxPro2.dll
/htdocs/mysite/JSTextrTransfer.aspx (and .cs)
The tech support says the url which refers AjaxPro has to be changed.
We changed the web.config entries to:
<scriptReplacements>
<file name="prototype" path="http://www.mysite.com/ajaxpro/prototype.ashx" />
<file name="core" path="http://www.mysite.com/ajaxpro/core.ashx" />
<file name="converter" path="http://www.mysite.com/ajaxpro/converter.ashx" />
</scriptReplacements>
Still no luck.
There is a 4th line for ashx in 'view source'.
<script type="text/javascript" src="/ajaxproTextTransfer,App_Web_jstexttransfer.aspx.5d7ed009.aexw4iuf.ashx"></script>
How can this dynamic entry be added in the web.config? Is this what is causing the error?
Or is there any other solution to overcome this?
Thanks in advance.
|
|
|
|
|
What is AJAX Pro ? Do they not have a forum ? I believe most people here use the ASP.NET AJAX extensions.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
Hiiiiiiii..........I am creating n number of text dynamically,and saving them in database and heading for all these text boxes is already saved in db and i m updating data of textbox in same database wid respective heading............but when i m going to save it updates last value to all fields. for e.g. if i m wrote ONE in last textbox then that value will be updated in all columns. My code is :
Dim id As Integer = Request.QueryString("ui")
Panel2.Visible = True
Panel4.Visible = True
Dim cmd2 As String = ("Select Specification from DefineSpecification where CategoryID=" + id.ToString())
Dim rdr2 As IDataReader = db.ExecuteReader(CommandType.Text, cmd2)
Dim conn As New SqlConnection
Dim cmd As New SqlCommand("Select Count(*) from DefineSpecification Where CategoryID=" + id.ToString(), conn)
conn.ConnectionString = ConfigurationManager.ConnectionStrings("See2Buy").ConnectionString
conn.Open()
Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar())
While rdr2.Read
Dim lbl = New Label()
lbl.Text = rdr2.Item("Specification")
Dim cmd3 As String = "Insert into Specification(ProductName,SpecificationHeading)Values('" + txtProductName.Text + "','" + lbl.Text + "')"
Dim dbcmd1 As DbCommand = db.GetSqlStringCommand(cmd3)
db.ExecuteNonQuery(dbcmd1)
For i As Integer = 0 To count
Dim txtCtrl As TextBox = DirectCast(Panel4.FindControl("txt" & (i + 1)), TextBox)
If txtCtrl IsNot Nothing Then
TextBox1.Text = txtCtrl.Text
Dim cmd4 As String = "Update Specification set SpecificationDescription='" + TextBox1.Text + "' where ProductName='" + txtProductName.Text + "' AND SpecificationHeading='" + lbl.Text + "'"
Dim dbcmd As DbCommand = db.GetSqlStringCommand(cmd4)
db.ExecuteNonQuery(dbcmd)
End If
Next
End While
|
|
|
|
|
Looks to me like you insert the same value from the textbox all the time. Your code is also bad for other reasons. The most obvious one - I can erase your database any time I like, because you do nothing to protect against SQL injection attacks.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
KhandelwalA wrote: I am creating n number of text dynamically,
Where did you crated the textbox? means in which event? If you are not creating dynamic textbox before Page_load() . and best to create in Page_PreInit() . Because all Postback data and ViewStore data restore just before Page_Load().
So if you create dynamic textbox before page_laod it will not able to hold the viewstate or postback data.
|
|
|
|
|
I am facing the following problem.
i have a solution file having more than one asp.net-c# project file.
I have added Web setup file to the solution and then add->group option, then the primary output and the content file of all the project to the setup project.
Then I have built it. And then installed it. This all the process was successfully done.
A virtual directory was created too.
But when I want to browse the site, i can see all the html pages. but no .aspx file. then I have discovered that there is no .aspx.cs file in the location.
I am deploying a project for the first time.
Please help.
Thanks in advance.
Anujit Karmakar
Software Programmer
|
|
|
|
|
Good Day Anujit
There are Different types of Deployment , Some don't have the CS some do have. In the Properties -->MSBuild Options, you will find that there is an option that says "Allow precompiled site to be updatable" or others , if one one them are checked then uncheck them and build your setup again and install it and the CS Files will be in your destination file.
Thanks
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Anujit wrote: but no .aspx file. then I have discovered that there is no .aspx.cs file in the location.
aspx file should be there. but there should have no aspx.cs file. And the reason is the deployment of web application (publishing). I will suggest you first read the article, then let me know if any doubts
WS Publishing
|
|
|
|
|
hi,
I am using sql database with asp.net in c#.I have a database application.HOw can i back up the data programmetically?
regards
Bill
|
|
|
|
|
this should help[^]
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
|
backup database 'dbname' to disk='C:\...'
Sabari MD
Application Developer
Veloxit Info Solutions
|
|
|
|
|
That is Simple
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- backup a database
ALTER PROCEDURE [dbo].[sp_BackupDatabase]
@databasename varchar(32),
@path varchar(256),
@filename varchar(64)
AS
set nocount on
declare @sql varchar(4000)
select @sql = 'BACKUP DATABASE ' + ltrim(rtrim( @databasename ))
select @sql = @sql + ' TO DISK = ''' + ltrim(rtrim(@path)) + ltrim(rtrim(@filename)) + ''' '
select @sql = @sql + ' WITH INIT'
--print @sql
execute ( @sql )
select 'Database successfully backed up!' [Result]
Welcome
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi Friends,
Im new in this and hope to get some advice.
I have to make a application to give advice to the students wich study direction they can choose.
They have to get a questionlist that they can awnser. The awnsers can be yes or no, or more then that, with 3 or more choices. The user can only select one awnser. So i have to use radiobuttonlists.
Now how can i implement this ? how can i make dynamically radionbuttonlists? what's the easist way to get this work?
Thanks
|
|
|
|