|
SayamiSuchi wrote: Is that because of not using postback thing
What do you mean by this? Does this mean you are using AJAX to get value from usercontrol to textbox and then textbox to DB?
Whatever the case is, did you debug it? What did you got?
SayamiSuchi wrote: On the button btn click event, i am getting values from user contro to the txtbox1. And on the same button click, i am using that txtbox1 value to insert into the database
Is it two client events working on the same button? If so, what is the order? Are they async? They need to be in order... synchronously.
Post a little code, if these doesnt help. The button click event part, the way you are binding the methods and whats in the menthod.
|
|
|
|
|
No error at all. Actually i have one user control in ascx page. And using that user control, i put that result in the textbox which is in aspx page. now the value which i am keeping from user control to that textbox is in button click event. now On the same button click, i am trying to use that textbox value for inserting into the database. but it is not sending that value to the database though once i click the button, that value is showing in that textbox. So just wondering is that because i didnt put the postback thing??
suchita
|
|
|
|
|
You need to be little more clear Suchita!
From what i got from your details, the flow should be:
1. Fill some value in Usercontrol ascx: ValueA
2. Press buttonA in ASPX parent page.
3. buttonA, brings ValueA in the textboxA of ASPX parent page
4. buttonA, send the ValueA in DB to store.
Now, if the sequence is right, they need to be SYNCHRONOUSLY, i.e. one after other.
Further, step 3 & 4 needs to be coded together in its handler. Add on if i missed something and also post a little part of your button click event.
|
|
|
|
|
you got it. But the problem is since the textbox is getting value and also textbox value is using for database in the same event, i think textbox value is not going to the database. But if i use the same thing in two events, its working fine. but i need that in a single event..
suchita
|
|
|
|
|
SayamiSuchi wrote: i think textbox value is not going to the database
For that, please share the event code! Once you get the value in ASPX, you should be able to save it.
|
|
|
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
{
WriteThisMessageToThePage1.sendMessageToThePage += delegate(string message){txtNeededDate.Text = message; };
WriteThisMessageToThePage2.sendMessageToThePage += delegate(string message){txtRequestDate.Text = message; };
cmd = new SqlCommand("INSERT INTO ProjectRequestInfo(ClientFName,ClientMName,ClientLName,Email,Extension,DepartmentName,ProjectTitle,ProjectDescription,DueDate,RequestDate,IntendedUsersAudience,SubmittedDate,NotificationTo) values('" + txtFirstName.Text + "','" + txtMiddleName.Text + "','" + txtLastName.Text + "','" + txtEmail.Text + "','" + txtExtension.Text + "','" + DrpDwnDepartmentList.SelectedItem.ToString() + "','" + txtProjectTitle.Text + "','" + txtProjectDescription.Text + "','" + txtNeededDate.Text + "','" + txtRequestDate.Text + "','" + txtIntendedUsers.Text + "','" + System.DateTime.Now.ToShortDateString() + "','" + getHighCnt + "')", conn);
conn.Open();
cmd.ExecuteNonQuery();
}
here i am getting value for txtNeededDate.text from message(i.e from usercontrol) and i am inserting the txtNeededDate.text to the database like that. It is not giving any error but it is not inserting value to database.
suchita
|
|
|
|
|
Could you just try putting a little delay after first two lines, before inserting in SQL?
like a dummy loop of 10,000 or so.
Or in debug mode, just put a breakpoint at cmd line and check what is the value of txtNeededDate.
|
|
|
|
|
Dummy loop is also not working...
suchita
|
|
|
|
|
From your code, there does not seem any problem.
One suggestion, yo could've public property in your usercontrol which gives the value that you want to update in textbox and use that property. This is cleaner and simple approach.
Debug your code and see where the problem lies.
Using the textbox to insert the data in DB should not be a problem. Also try using a local variable assign this first, then use this to insert in DB, might be you get the problem.
|
|
|
|
|
I tried using local variable too but the same problem...
suchita
|
|
|
|
|
Ya i tried with debug mode. textboxes are not getting values within that event. After that event, they are getting values.. So what can be done for such problems ??
suchita
|
|
|
|
|
Can anyone point me to some sample code in C# for converting an html table to image?
Praveen Kumar.R
|
|
|
|
|
|
I would like to create a horizontal menu based on a vertical menu that I click on home for example a vertical menu appears, if someone can give me advice or proposal
thank you
|
|
|
|
|
|
thank you for those links, but despite that, I could not do this action, display a vertical menu by clicking on a horizontal menu, please help me
|
|
|
|
|
Hi All,
I'm user VS 2005 and wanted to know if it's possible to create a user control that can be used in both a Windows Application and a WebSite?
I'm coding in C# with ASP.NET.
I'm wanting to create a control like the DateTimePicker, which is available when creating Windows Applications, but it doesn't seem to be available when creating WebSites. Please tell me if I'm wrong, this way I can build upon the existing control. Thanks.
If you know of any websites that might be useful, I would be very geratful if you shared them.
Thanks in advance.
Mel
|
|
|
|
|
MWRivera wrote: a user control that can be used in both a Windows Application and a WebSite?
Not possible, they are two separate environments.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
You are right but... he wanted to develop only 1 control for both Web & windows... which is not feasible as they both are totally different.
He only can develop something similar look wise and they way the works but they have to be two different controls!
|
|
|
|
|
Thanks for the replies guys. I guess I was hoping for a long shot.
Yes you're right Sandeep I was asking if I it was possible to create a single control taht could be used in both enviroments.
Does anyone know any alternative was of create a control that can be used within both enviroments. Or is there no avoiding two seperate controls?
Thanks,
Mel
|
|
|
|
|
Hi guys,
I am executing a stored procedure from my webservices, i would like this store procedure to check is a userid exist and if it does then i would like to return a value saying so.
Here is a quick proc...i don't know how to carry on from here.
USE [reportserver]
GO
--Create the Procedure
CREATE PROCEDURE FindCurrentUser(@userid VARCHAR(10), @RowCount VARCHAR(10) output)
AS
BEGIN
IF EXISTS(SELECT * FROM [UserProfile] WHERE [userid] = @userid)
BEGIN
RETURN @RowCount = 'Exists'
END
ELSE
BEGIN
RETURN @RowCount = 'NotExists'
END
END
but it gives me an error:
'Incorrect syntax near '='
Any help please??
Thanks,
Morg
|
|
|
|
|
Here's one way:
USE [reportserver]
GO
--Create the Procedure
CREATE PROCEDURE FindCurrentUser(@userid VARCHAR(10))
AS
BEGIN
declare @RowCount varchar(10)
IF EXISTS(SELECT * FROM [UserProfile] WHERE [userid] = @userid)
BEGIN
set @RowCount = 'Exists'
END
ELSE
BEGIN
set @RowCount = 'NotExists'
END
select @RowCount as Counter
END
me, me, me
"The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!"
Larry Niven
|
|
|
|
|
Thanks man,
that was great help
|
|
|
|
|
I wouldn't use rowCount since it is a reserved word. Also I think you are making it more difficult on yourself by requiring hard coded strings. Hard coded strings for program control flow are bad. All you need is this:
select count([userid]) from [userprofile] where [userid]=@userID
Then in your C# you can just check for > 0.
|
|
|
|