|
Brij wrote: One more thing, why you are taking the help of session, you can use viewstate.Enable the viewstate of the contrls on the page that will suffice your requirement.
Relation of textbox and ViewState is something different with respect to other controls. If you make EnableViewState=False; for Textbox, still it will maintain the postback data. Why ?
First of all you need to know what actually happened during ASP.NET Page life cycle and ViewState .
In the ASP.Net page life cycle, two events related with View State.
1. Load View State : Where view state data is loading for the control and which happened before Page_Load.
2. Save View State : Where control data store in a hidden field before the Page_Render.
Now, If you disable the ViewState for the control it should store the view state data but, you are saying in Textbox, after you disabled the view state , control holds the data after postback,
Here is the Trick, There is another event fired during Page Life Cycle, which is, Load PostBack Data
ASP.NET controls which implement IPostBackEventHandler will load its value from the appropriate postback data. This value is not read from view state but from Postback From and this is true for those control which implements the IPostBackEventHandler and TextBox is one such control.
Hope you got my point.
|
|
|
|
|
You are right Abhijit. But Load PostBack Data is called only for input controls those implement IPostBackEventHandler . For rest of the controls, viewstate could be used.
Thanks for adding it in detail.
|
|
|
|
|
lvq684 wrote: Really hope you can help me understand this!
can you Please show us the code block ?
|
|
|
|
|
Thanks alot for all your answers.
I´ve tried with the viewstate, but It didnt really work. It prolly would have if I tried for a longer time
Instead I found out that the page load method is called several times, even if the page isnt loaded. So in that way the old values were set.
But how come the page_load method is called often, even if the user hasnt done anything on the page?
Thanks again
|
|
|
|
|
Hi All,
I am converting HTML to PDF using itextsharp.dll. My HTML conatins table and
many rows. When a row goes to next page, its cells data is not shown in pdf
document. Initially, I fixed it by changing top and bottom margins. But it
caused problem in other cases. Note that I am getting HTML from user
control. When I copy this HTML in htm file, It shows all the data correctly.
But in pdf it does not show.
Any help?
Thanks,
Pervaiz Niazi
|
|
|
|
|
hi, iam using asp.net with c#
when iam trying to execute this querry iam getting error
can you correct my querry
SqlCommand cmdallltransactions = new SqlCommand("SELECT SUM(Amount)FROM AllTransactions WHERE (TransCode <> 0) GROUP by BranchKey="+Convert.ToInt32(Session["BranchKey"])+"", con);
con.Open();
txttotal.Text = Convert.ToString(Convert.ToInt32(cmdallltransactions.ExecuteScalar()));
con.Close();
error iam getting is
Incorrect syntax near '='.
|
|
|
|
|
SELECT SUM(Amount)
FROM AllTransactions
WHERE (TransCode <> 0)
AND BranchKey = 'branchkey'
You should also look at parameterizing your query.
|
|
|
|
|
i have created drop downdownlist and i m binding it with the testnames in the database.
Private Function load_sptestreqtestnameddl()
Dim Adptr As New SqlDataAdapter
Dim Pkgddldt As New DataSet
'################## FOR CONNECTION ################
Dim MySearchCon As DbConnection = providerFactory.CreateConnection()
MySearchCon.ConnectionString = connectionString.ConnectionString
'################### END OF CONNECTION #################
Dim str As String = Nothing
str = ("SELECT test_id, test_name FROM TestName")
Adptr = New SqlDataAdapter(str, MySearchCon)
Adptr.Fill(Pkgddldt)
sptestreqtestnameddl.DataSource = Pkgddldt
sptestreqtestnameddl.DataSource = Pkgddldt.Tables(0)
sptestreqtestnameddl.DataTextField = Pkgddldt.Tables(0).Columns("test_name").ColumnName.ToString
sptestreqtestnameddl.DataValueField = Pkgddldt.Tables(0).Columns("test_id").ColumnName.ToString
sptestreqtestnameddl.DataBind()
Return 0
End sub
the code shows me following error....this exactly same code works perfect in other webforms.
'sptestreqtestnameddl' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value
|
|
|
|
|
hi,
After filling the data adapter, please clear the dropdown then try to bind.
sptestreqtestnameddl.Items.Clear();
Seems to me after binding list, dropdown tries to select a value that is not even in the dropdown list.
Thnaks
|
|
|
|
|
Just specify columns in DataTextField and DataValueField like this:
sptestreqtestnameddl.DataTextField = "test_name"
sptestreqtestnameddl.DataValueField = "test_id"
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Hi, I'm writing a control of the dynamic in a
existing page is added.
You gotta think of a content management system, to a already
existing page will be added a User Control.
In this Usercontrol is used an UpdatePanel and ModalPopup.
To use these elements I need a script manager
I can not add an the Script Manager to my UserControl even one already existing Page in the CMS in my control will be added??
Are there any opportunities?
I hope you understand what I mean ....
Regards
|
|
|
|
|
If I understood you correctly, you're asking if only one ScriptManager per Page is allowed.
Yes, there can be only One.
I usually solve the problem by using a masterpage with a scriptmanager.
Don't insert the sriptmanager in your control, only the updatepanel(s).
Further reading : http://msdn.microsoft.com/en-us/library/bb398864.aspx[^]
Cheers
I don't like my signature at all
|
|
|
|
|
But how shoul i use a Master page if i write a Usercontrol who can be added in a Page?
I understand you wrong or just what?
So according to your proposal, it would mean that I have in my control in a MasterPage and who is my Script Manager?
Where shall I find my ModalPopup and update panels?
|
|
|
|
|
You don't need to change your usercontrol, just don't put a scriptmanager in it.
If you create a masterpage in your site which has a scriptmanager on it, you can drop or create your usercontrol on any page the has that masterpage.
It's a design issue :
- if a usercontrol has a scriptmanager on it, you can only put it in a page once.
- if you put the scriptmanager on a (content)page, there can be no usercontrols that have a scriptmanager.
- if you want to put your usercontrol on more than one page, you have to put a scriptmanager on every page that uses it.
Does the term "Webpart" mean anything to you? What you are trying to do sounds a bit similar to me.
Cheers
I don't like my signature at all
|
|
|
|
|
I have heard of but have not used it yet why?
I can not use MasterPage because the design is already given!
Its look like this in our cms
So Imagine somebody can add my Control right now into the Page(Template)! So This Page is already present with a Scriptmanager.
Klick ME
|
|
|
|
|
Ok, then go for the page, just DON'T put a scriptmanager in your own usercontrol.
It is an option to check in your code if a scriptmanager exists, if it doesn't then create it, before your ajax controls (ie UpdatePanel(s)) are loaded.
Cheers
I don't like my signature at all
|
|
|
|
|
Hmm will check it! But Hmm what shall i do if its already exsist?
What are developing so far?
|
|
|
|
|
This is what I once did :
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
private ScriptManager_AjaxManager = ScriptManager.GetCurrent(this.Page);
if (_AjaxManager == null)
{
_AjaxManager = new ScriptManager();
_AjaxManager.EnablePartialRendering = true;
_AjaxManager.EnableScriptLocalization = true;
if (this.Page.Form != null)
{
this.Page.Form.Controls.AddAt(0, _AjaxManager);
}
}
}
Mind you, if the scripmanager already exists, set the properties right!
Cheers
I don't like my signature at all
|
|
|
|
|
ok that's obvious , what is to do, which properties must be set right?
Its possible to write a oder Control who contains only a scriptmanager? This Control could i add into my other Contro the contains updatepanels etc...l.
Will be possible or?
|
|
|
|
|
There can only be one scriptmanager.
I don't know if we are conversing on the same subject.
- Declare the ScriptManager at Page level (because you can't put it in a MasterPage).
- Either put your usercontrol inside an UpdatePanel or contain your controls within an UpdatePanel in your usercontrol.
My example only suggested a way to dynamically put a ScriptManager on the Page. Which properties should be set is completely up to you.
Cheers
I don't like my signature at all
|
|
|
|
|
ScriptManager
A server control that makes script resources available to the browser, including the Microsoft AJAX Library and the functionality that enables partial-page rendering.
A server control that enables nested components to add script and service references if the page already contains a ScriptManager control.
It is possible to add a ScriptManagerProxy to my UserControl?
|
|
|
|
|
Hi
how to execute server side code in asp.net while using jquery.
like some login form is opened by using jquery as model popup and how will be executed submit button click event.
or any other way while using jquery to perform login form functionality.
thanks
You get the best out of others when you give the best of yourself.
|
|
|
|
|
trilokharry wrote: execute server side code in asp.net while using jquery
The most common method I use for this purpose is WebMethod.
1. Create a webmethod in your code behind.
[System.Web.Services.WebMethod(EnableSession = true)]
public static string DemoMethodInCodeBehind(string msg)
{
return "OK_" + msg;
}
2. Write a javascript function to call this web method.
function demo()
{
PageMethods.DemoMethodInCodeBehind('hello',OnGetMessageSuccess, OnGetMessageFailure);
}
3. Implement success & failure methods in java script.
function OnGetMessageSuccess(result, userContext, methodName)
{
alert("Success " + result);
}
function OnGetMessageFailure(error, userContext, methodName)
{
alert("Failed");
}
4. Now call Demo on button click.
|
|
|
|
|
not getting exactly what to do with this code.
I tried but no output.
I'm new in jquery so please help me.
You get the best out of others when you give the best of yourself.
|
|
|
|
|