|
Hey guys, I'm having a small problem with a scalar variable. I took the code from another project I wrote but there were a few changes in this new project so I wasn't able to do the same thing as last time. Anyway, now I'm getting the error "Must declare the scalar variable "@State".", mostly because I'm not exatly sure where to declare it.
The code is a bit scattered, but I'll try to make it as short as I can, without leaving anything out. Although I think the problem is in the SqlDataSource with the select prameters / control parameter
EDIT: In hindsight I really should have specified what I'm trying to do. There is a drop down list where users will pick a state of a variable from a database, then the infomation matching that state will be displayed accordingly.
Drop Down List:
<asp:DropDownList ID="DropDownList1"
runat="server"
DataSourceID="myFilteringDataSource"
DataValueField = "State"
AutoPostBack = "True">
</asp:DropDownList>
The SqlDataSource:
<asp:SqlDataSource ID="myFilteringDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT DISTINCT State FROM tblTicket" >
<SelectParameters>
<asp:ControlParameter Name="State" ControlID="myDropDownList" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
The VB/SQL code which would interact with the "@State":
Dim cmd As New SqlCommand("SELECT * FROM tblTicket ... WHERE ... tblTicket.State = @State", New SqlConnection(strCon))
cmd.Connection.Open()
Dim myReader As SqlDataReader = cmd.ExecuteReader()
The actual error I was talking about ("Must declare the scalar variable "@State".") comes up at 'Dim myReader As SqlDataReader = cmd.ExecuteReader()', so I pretty much know that I just have the variable delared in the wrong place.
I'd really appreciate any help, and if any more code is needed I'll post it right away.
Thanks,
aqzman
|
|
|
|
|
Most of your markup is not visible. Use the "Ignore HTML" option when you are posting markup code.
You have to add a parameter to the command object. The parameter that you have added to the SqlDataSource isn't used, as you don't use the SqlDataSource.
---
single minded; short sighted; long gone;
|
|
|
|
|
Oh, thanks for letting me know about that. I really should have looked over my message once it was posted.
I'm not exatly sure what you mean by it isn't used, the SqlDataSource is called in DataSourceID of the dropdownlist. Or maybe I've misunderstood you.
Thanks for the help!
aqzman
|
|
|
|
|
aqzman_ wrote: I'm not exatly sure what you mean by it isn't used, the SqlDataSource is called in DataSourceID of the dropdownlist. Or maybe I've misunderstood you.
The SqlDataSource is used on the page, but it's not used in the code that you have problems with.
---
single minded; short sighted; long gone;
|
|
|
|
|
hi dear friend's
how can i change the type property of a textbox from 'text' to 'password' with javascript??
thank you
msma
|
|
|
|
|
|
thank you but i need a code to change the type property of a textbox(html element) from 'text' to 'password'
msma
|
|
|
|
|
mr.mohsen wrote: how can i change the type property of a textbox from 'text' to 'password' with javascript??
You can't. Once the type has been set for an input element, it can't be changed. You have to create a new element.
---
single minded; short sighted; long gone;
|
|
|
|
|
Yeah one option would be to have two textboxes on the page. Then change the Style.Display property to show one or the other which can be done easily with Javascript.
I didn't get any requirements for the signature
|
|
|
|
|
hi dear friend's
oh my god
im alone and alone
and nobody close me
no body know me
nobosy love me
nobody like me
but i have u
you like me
u love me
u power me
and u are all of my things...
thank u
|
|
|
|
|
Bad poetry certainly does NOT belong in a programming forum.
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
He must be a Vogon.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hi all,
I'm trying to load a user control dynamically into a web form. As I understand it, in order for the Placeholder to have a viewstate, I need to load the control in it before the Page load. So I'm trying to do that in the OnPreLoad method.
I have a link button on the web form. When I click it, I would like to load the user control in the placeholder. The first thing I do is save the UniqueID of the link button in the session. Now in order to be able to check which control has triggered the postback, I match the saved value in the session with the value of this.Request.Form["__EVENTTARGET"] . If they are equal, I go ahead and load the control.
Now the issues I'm having:
First, when the page loads for the first time, I have a javascript error that says
'null' is null or not an object
The page continues to work however and when I click the link button, the user control is loaded and is displayed.
Now I have a button in the user control, when I click it, the user control disappears again on postback. I'm guessing this is because the placeholder didn't hold the viewstate as I expected. Would that be due to that Javascript error? The code I'm using is this:
if (this.Request.Form["__EVENTTARGET"] == (string)Session["linkID"])
{
uc = (UserControl)Page.LoadControl("modules/AddFeatureType.ascx");
PH_AddFeature_AddType.Controls.Add(uc);
}
where uc is declared globally in the page class.
When I remove this code, no javascript error anymore.
So my questions are: 1-Has anyone encountered a similar javascript problem and if yes, what is causing it exactly? 2-Is OnPreLoad the correct method to place the user control load process to maintain viewstate during postbacks?
Any other insights or issues concerning dynamic user control loading are welcome and appreciated.
Thanks.
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Ok I found the problem. In the beginning I was loading the user control statically in the web form and then when I wanted to try to load it dynamically, I commented the line where I call it.
<td>
<asp:PlaceHolder ID="PH_AddFeature_AddType" runat="server"></asp:PlaceHolder>
<!-- <aft1:AddFeatureType ID="AddFeatureType" runat="server" />-->
</td>
This resulted in the comment tags to appear in the html code, I have no idea why actually. Anyway, I removed the comment completely and now the page loads without javascript errors and when i click the button in the user control, the required field validator of my textbox works.
Now I have another issue related to the field validators, I'm not sure if I should created a new thread for it or not.
In that same page with the user control, I have 1 textbox in the webform and 1 textbox in the user control, both have required field validators attached to them. I also have two buttons, one in the web form and one in the user control.
My problem is that when i click the button inside the user control, the field validator of the textbox located in the web form activates. My question: is there a way to have some kind of scope for the button? I would like only the field validator of the user control to activate when i click the button inside the user control. Is there a way to accomplish such a thing?
Thanks.
Talal
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Hi all,
I have an ASP.Net 2.0 application that my customers use. I now have the need to allow my customers to connect via their PDAs. Just one ASP.Net page is involved here. This page has a Gridview control and the user can enter some info which updates a SQL table. The gridview has some textboxes where the user can change some values. Pretty standard stuff. So I made the gridview real small so that it will fit on a PDA. Everything works except that my textboxes are very wide. I tried making the width small but no luck. But other properties like font=bold, font-size, forecolor, etc. I can change and these change do appear on the PDA. But everything I try to make the width small fails. It is very frustrating since this will perfectly if I can just get these darn widths correct! I know there is a mobile framework and special controls just for mobile devices. But that would require me to write a new web page and learn about these new controls. I was hoping I could salvage my existing web page. Can anyone help?
Thanks,
Bob
|
|
|
|
|
hi,
Is it Possible to create a base web control and then inherit from it in other user web controls?
For example, id like to create a web control that encapsulates all the ajax logic, a title bar, some buttons etc. Then id like to create some sub controls that would inherit from that, so that i could create, for example a gridview control, and it would be ajax enabled and have a title bar etc...
I cant see any way to do this in visual studio (2005). When i create a control, i cant set that as the superclass for another control, ie: inherit from it.
Ive been programming for several years, but never worked on a web project large enough to think about something like this. If its not possible, what are the general ways people encapsulate common functionality in web controls on the web?
Thanks
|
|
|
|
|
Dermot O S wrote: When i create a control, i cant set that as the superclass for another control, ie: inherit from it.
Yes, you can.
What have you tried that led you to believe that you can't?
---
single minded; short sighted; long gone;
|
|
|
|
|
Well, In a web project, I create a control and call it BaseControl.ascx I put some text into it eg: "This is the base control".
I then create another control and call it MyControl.ascx. I modify the code-behind to inherit from BaseControl instead of System.Web.UI.UserControl and in the markup i change the Inherits= value to BaseControl.
I attempt to build it and i get 5 errors
I get 4 x
Error 1 'Context' is not a member of 'BaseControl'. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\sitetwo\51cc156d\f50c0ac4\App_Web_ms78fiky.0.vb 37
and one:
Error 3 property 'SupportAutoEvents' cannot be declared 'Overrides' because it does not override a property in a base class. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\sitetwo\51cc156d\f50c0ac4\App_Web_ms78fiky.0.vb 68
When I double click the errors it brings me into that randomly named, auto generated file: App_Web_ms78fiky.0.vb
Am I doing this wrong? Thanks for your previous quick reply by the way.
|
|
|
|
|
I don't think you need to change the inherits= value in the markup...
|
|
|
|
|
Paddy is right. The Inherits property determines what class the ascx page is inheriting from, and you don't want to change that, as that would turn the ascx page from a "MyContol" to a "BaseControl".
---
single minded; short sighted; long gone;
|
|
|
|
|
Either way it doesnt work, its still the way i described it in my first post.
|
|
|
|
|
I have install first VS 2005 and then VS 2003.
Now i am getting subject error while debug any vs 2003 ASP.NET project.
Can anyone please guide what i have missing.
|
|
|
|
|
aquarious2020 wrote: Now i am getting subject error while debug any vs 2003 ASP.NET project.
What is "subject error"? Can you please post the error message that you are getting?
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.
|
|
|
|
|
You wrote: Unable to start debugging on web server
Okay. got you.. (At least, you should re-write the error message instead of saying "subject error".)
I and my team used to face that problem sometime ago. I will tell you all attempts that we made while trying to solve that problem. I'm not sure which attempts actually solved the problem but I'm sure the problem will be solved after trying all attempts.
Check-out this link. I posted about this last month..
[Weekly - QASW] - Questions and Answers in Software Development
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.
|
|
|
|
|
Hi,
I am a newbie and developing a web application in ASP.NET 2005. In one of my page I am having three different Usercontrols. However when I run my page in FF everything seems fine even after postback. But in IE after Pageload when i click buttons or even change options from Dropdown nothing appears to happen.(My dropdown is having event "SelecetedIndexChanged" and Autopostback is also set as true). Although the page postbacks, but rather to go in any event handlers (except Page_Load) it directly jumps to usercontrols.cs file after checking postback property and leaves from there right only rather to continue with specific eventhandlers. I tried by removing one of my user controls and everything works fine. I don't know how to solve this problem. I have also used EventValidation="false" in Page property section but of no use.
Just surprised to see FF is working fine with the same user controls and I even dont have any particular settings for my IE browser.
I modified, developed a new Usercontrol but alas of no use.
My Usercontrols HTML code is satisfying all W3c norms and nothing seems wrong in it (I hope so) and attached here.
Need Immediate Help,
Any Replies appreciated.
Thanks,
naresh511@gmail.com
User Controls HTML Code:
| | | Forgot Username or password? |
|
|
|
|
Naresh
|
|
|
|