|
I haven't tried this, but as you said property is working fine, then have a property like this
public string GetValue
{
get
{
return methodName();
}
}
And use this property.
|
|
|
|
|
yes, but its gonna run this method every time i create an object.
i want only run this method when i need..
i gonna read your article,
thanks for answer
|
|
|
|
|
marijus5 wrote: but its gonna run this method every time i create an object.
Have some logic when you wanna create it else you can also store it somewhere say viewstate etc...
marijus5 wrote: i gonna read your article
Pls share your feedback
|
|
|
|
|
hi guys im actually working on C# web application on VS2003(Version 1.1) in my web page i have a date picker now the date gets stored in a string this way:
string FrmDt=DtP_frm.Text.Replace("/","");
so the string stored here is in format like this --> 12042010, with this string i retrieve my records from database with search query. but in the database i have to pass this string as --> 20100412 which is yyyymmdd format... How do i achieve this...
Any advise is appreciated...
Thanx in advance,
Tash
|
|
|
|
|
<<tash18>> wrote: string FrmDt=DtP_frm.Text.Replace("/","");
In here, before replacing the '/', convert into the yyyymmdd format that you need and then replace the '/', pass on as search parameter to Database.
Like:
String tempDate = Convert.ToDateTime(DtP_frm.Text).ToString("yyyy/MM/dd");
Now use this tempDate for your manipulation of removing the '/' and passing to DB.
|
|
|
|
|
Hi,
I have basically the following structure set up :
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" ... >
:
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" ... >
</asp:ObjectDataSource>
<asp:ImageButton ID="NewInsertButton" runat="server" OnClick="NewInsertButton_Click" />
<asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource2" ... >
<InsertItemTemplate>
:
<asp:FileUpload ID="FileUpload1" runat="server" />
:
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Insert" />
</InsertItemTemplate>
:
</asp:FormView>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" ... >
</asp:ObjectDataSource>
</ContentTemplate>
</asp:UpdatePanel>
I am aware that a FileUpload requires a full page postback. I read the article
http://www.4guysfromrolla.com/articles/090209-1.aspx[^]
I tried to install a PostBackTrigger programmatically to get a full postback only on the ImageButton1 control. All other postbacks must be partial. (GridView sorting, paging, ...)
In code behind I do :
protected void NewInsertButton_Click(object sender, ImageClickEventArgs e)
{
FormView1.ChangeMode(FormViewMode.Insert);
FormView1.DataBind();
ImageButton InsertButton = FormView1.FindControl("ImageButton1") as ImageButton;
if (InsertButton == null)
throw new NullReferenceException("ImageButton1");
ScriptManager Manager = ScriptManager.GetCurrent(Page);
if (Manager == null)
throw new NullReferenceException("ScriptManager");
Manager.RegisterPostBackControl(InsertButton);
:
}
The above code does not seem to install a full postback only for the ImageButton1, so the file upload fails. How can I make this work ?
|
|
|
|
|
Because I can't work with your code as prsented
I will give this very simple example of an udatepanel
containing a button for update and another button for
postback ...
Hope it helps .
<%@ Page Language="C#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e){
if (Page.IsPostBack) { myLabel.Text = "posted back"; }
ScriptManager current = ScriptManager.GetCurrent(Page);
if (current != null)
{ current.RegisterPostBackControl(Button2); }
}
protected void Button1_Click(object sender, EventArgs e)
{
DropDownList1.Items.Clear();
String[] ds = {"hi RED","sup RED"};
String[] ds1 = { "hi BLUE", "sup BLUE" };
if (DropDownList2.SelectedValue == "RED")
{ DropDownList1.DataSource = ds;
DropDownList1.DataBind(); }
if (DropDownList2.SelectedValue == "BLUE")
{ DropDownList1.DataSource = ds1;
DropDownList1.DataBind();
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<style type="text/css">
#UpdatePanel1 { width:300px; height:100px; } </style>
</head>
<body>
<form id="form1" runat="server">
<div style="padding-top: 10px">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem>RED</asp:ListItem>
<asp:ListItem>BLUE</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="UpDate" />
<asp:Button ID="Button2" runat="server" Text="PostBack" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:Label runat="server" ID="myLabel"></asp:Label>
</div>
</form>
</body>
</html>
modified on Sunday, April 18, 2010 10:49 AM
|
|
|
|
|
Thx for the reply. I appreciate your effort. I tested your code, and yes it works,
but in my case I use form views which creates their embedded controls dynamically.
I found numerous examples on the net, demonstrating how it has to be done, but I found
none which resembles my senario.
For one reason or another my code does not function, and I would like to know why.
|
|
|
|
|
If you could present some very brief but complete
code that illistates your problem I could easily
correct it, but it must be brief and complete.
|
|
|
|
|
Hello,
I have been creating a simple gridview in an asp.net application connected to sql server. Everthing works fine on the local development site, when I deploy I get the following error.
Invalid column name 'ClientID'.
Invalid column name 'ContractorID'.
Invalid column name 'ProjectType'.
Invalid column name 'HideProject'.
Invalid column name 'StartOnSite'.
Invalid column name 'Completion'.
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.SqlClient.SqlException: Invalid column name 'ClientID'.
Invalid column name 'ContractorID'.
Invalid column name 'ProjectType'.
Invalid column name 'HideProject'.
Invalid column name 'StartOnSite'.
Invalid column name 'Completion'.
The gridview has been created using visual studio 2008, without modification, and points to a view based on 3 tables. I have re-created both the gridview and tables several times. The view was scripted from the local sql server on the remote server, using Create View with SET QUOTED_IDENTIFIER ON and also turned off. I have removed all parameters, so theres nothing that could trip up the query. The query runs fine on the remote server when I look at it with Management Server. I have also tried changing all the fields on the gridview to template fields, so I can see the bindings and check for upper and lower cases, and everything is fine. I have checked through lots of articles and this is usually due to missing columns on the view or table, or upper and lower cases in the mark up; but they are all fine and work in the development environment?
This is driving me mad. Since the view runs on the server without problems, it must be the asp.net gridview thats tripping out. But I can't see it.
Here is the gridview markup.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" <br />
BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" <br />
CellPadding="3" CssClass="menutxt" DataKeyNames="ProjectID" <br />
DataSourceID="ProjectListing" GridLines="Vertical"><br />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" /><br />
<Columns><br />
<asp:BoundField DataField="ProjectID" HeaderText="ProjectID" ReadOnly="True" <br />
SortExpression="ProjectID" /><br />
<asp:BoundField DataField="ClientID" HeaderText="ClientID" <br />
SortExpression="ClientID" /><br />
<asp:BoundField DataField="ProjectName" HeaderText="ProjectName" <br />
SortExpression="ProjectName" /><br />
<asp:BoundField DataField="ContractorID" HeaderText="ContractorID" <br />
SortExpression="ContractorID" /><br />
<asp:BoundField DataField="ProjectType" HeaderText="ProjectType" <br />
SortExpression="ProjectType" /><br />
<asp:BoundField DataField="Description" HeaderText="Description" <br />
SortExpression="Description" /><br />
<asp:CheckBoxField DataField="HideProject" HeaderText="HideProject" <br />
SortExpression="HideProject" /><br />
<asp:BoundField DataField="StartOnSite" HeaderText="StartOnSite" <br />
SortExpression="StartOnSite" /><br />
<asp:BoundField DataField="Completion" HeaderText="Completion" <br />
SortExpression="Completion" /><br />
<asp:BoundField DataField="CompanyName" HeaderText="CompanyName" <br />
SortExpression="CompanyName" /><br />
</Columns><br />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" /><br />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /><br />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" /><br />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" /><br />
<AlternatingRowStyle BackColor="#DCDCDC" /><br />
</asp:GridView><br />
<asp:SqlDataSource ID="ProjectListing" runat="server" <br />
ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>" <br />
SelectCommand="SELECT [ProjectID], [ClientID], [ProjectName], [ContractorID], [ProjectType], [Description], [HideProject], [StartOnSite], [Completion], [CompanyName] FROM [About_VProjectList]"><br />
</asp:SqlDataSource>
What school boy error am I making that I just can't see?
|
|
|
|
|
Have you checked the conneciton string? Is it pointed to the correct database?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark,
Thanks for the reply, I have now sorted the problem. I stopped, grabbed a beer and started again from scratch. The problem was the order of the tables as I brought them into the view. The main table with Project information was not selected first. This obvuiosly effects the order of the inner joins. It seems the remote database is more sensitive than the development database. It worked locally, but crashed on the server. Opening both Visual Studio and Management Studio, I created the views together, selecting the main table first, then the forein key tables, making sure to select the columns in the same order. This appears to have resolved the error. I am now going to carry on with the beer. Regards, Tony
|
|
|
|
|
|
Hi.
Please help me with this as i am also getting the same error.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Prod_code" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="Prod_code" HeaderText="Prod_code" ReadOnly="True"
SortExpression="Prod_code" />
<asp:BoundField DataField="Prod_cate_id" HeaderText="Prod_cate_id"
SortExpression="Prod_cate_id" />
<asp:BoundField DataField="Prod_name" HeaderText="Prod_name"
SortExpression="Prod_name" />
<asp:BoundField DataField="Prod_desc" HeaderText="Prod_desc"
SortExpression="Prod_desc" />
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="image1" runat="server" ImageUrl='<%#"Handler.ashx?Prod_code="+Eval("Prod_code") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:BoundField DataField="Status" HeaderText="Status"
SortExpression="Status" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:centurydbConnectionString2 %>"
SelectCommand="SELECT [Prod_code], [Prod_cate_id], [Prod_name], [Prod_desc], [Prod_image], [Price], [Status] FROM [Prod_detail1]">
</asp:SqlDataSource>
Please help me with this error................................
|
|
|
|
|
how can we check whether a list item in radio button list is selected or not,
without using for each loop or javascript
Known is a drop, unknown is an ocean
-- Modified Sunday, April 18, 2010 6:24 AM
|
|
|
|
|
Are you trying at serverside. If yes, then you can get via prperty SelectedItem.It returns null if no item is selected.
Are you looking for somthing else?
|
|
|
|
|
You can check it with SelectedIndex Properties.
if (RadioButtonList1.SelectedIndex > -1)
{
Response.Write(RadioButtonList1.SelectedIndex.ToString());
}
else
{
Response.Write("No Item Is Selected");
}
Cheers !
Abhijit Jana | MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Hello, This Is Vikash Gohil.
I need some guideline/help on the following issue.
I have a webpage with a function written on Page_load event which takes the arguments from url using querystring and prints a single line on the page after execution of the function.
Now as per my knowledge, if i need to execute that function, i need to provide the full url in the address bar of the browser along with arguments needed.
Now what i want is, I dont want my webapp to redirect to that webpage but still need the function on that page, to get executed with the dynamically passed argument values.
Now, in first place, is this thing possible?
If yes, then can someone tell me the way to do it.
if no, then can i achieve this functionality in some other way?
All i want is the user must not be redirected, but still want to execute the function on another page.
Awaiting a reply soon, any help would be highly appreciated.
Thanks in Advance.
|
|
|
|
|
Whatever code you have written in the Page_Load event of the webpage should be removed and kept in a method in some other class. You can have something like Common.cs where you can put all the methods which are to be used across the webpages.
|
|
|
|
|
Hello, danish.
Thanks for your response.
But the problem is I cannot change any code as it is not my creation, it is like a 3rd party Control so i can only use it and not change anything.
But anyway thanks for the reply.
|
|
|
|
|
|
Hello, Chetan.
Thanks for your reply.
But what I want is not hiding the actual URL from the user.
My actual requirement is to execute code written in page_load event on another page without redirecting to that page.
Is this thing possible?
Please reply.
|
|
|
|
|
Use Server.Transfer
Best Regards,
Chetan Patel
|
|
|
|
|
hi Friend's
Suppose i have one application which having session time out set as 45 min, now the scenario is suppose one user login and activate that session and close the browser without login off.
what happen to that session?
Is that session automatically terminate by garbage collection?
Or still remain active and if so then how to handle this session?
Thank's and regard's
Sasmi
|
|
|
|
|
Session will kill automatically after the defined time frame.
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|