|
Hi All,
I created a link button dynamically. using following code
LinkButton lbt = new LinkButton();
lbt.Text = objDt.Rows[j]["sub_grd"].ToString();
lbt.Click += new EventHandler(ctrl_Click); // not working
//then i used
lbt.Attributes.Add("OnClick", "ctrl_Click();"); // not working
Please Help me...
Note : i tried a lot using google help befor posting this thread.
|
|
|
|
|
Did you re-bind the events at postback? You would need to.
|
|
|
|
|
I donk know how to rebind the event please tell me ..
|
|
|
|
|
Let the same code run on each postback! You must be skipping the formation of the button and event assignment on consecutive postbacks.
|
|
|
|
|
On Pageload event repeat the above code
|
|
|
|
|
write this code in
protected void Page_PreInit(object sender, EventArgs e)
{
LinkButton lbt = new LinkButton();
lbt.Text = objDt.Rows[j]["sub_grd"].ToString();
lbt.Click += new EventHandler(ctrl_Click); // not working
//then i used
lbt.Attributes.Add("OnClick", "ctrl_Click();"); // not
}
private void ctrl_Click(object sender, EventArgs e)
{
}
dont write in
protected void Page_Load(object sender, EventArgs e)
{
}
|
|
|
|
|
Hi Visnu,
Thanks for helping me. It does not change the behaviour of link button.
Page_PreInit(object sender, EventArgs e) calls the functions to creats the button programatically but when i click the link button then the dynamic table gets disapeared.
for the solution of problem i wrote the code in the Page_load event and got the results.
But my question, Is it good thing to call same function again and again and get data from database to create table dynamic for same page?
|
|
|
|
|
Check this, it will help you.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="dynamicButton.aspx.cs" Inherits="dynamicButton" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</div>
</form>
<script >
function jsEvent() {
alert("hai");
}
</script>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class dynamicButton : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button button = new Button();
button.ID = "Button1";
button.Text = "DynaicButton";
button.Attributes.Add("onclick", "return jsEvent();");
button.Click += new EventHandler(button_Click);
PlaceHolder1.Controls.Add(button);
}
protected void button_Click(object sender, EventArgs e)
{
Response.Write("Server Event: From Dynamic Button");
}
}
Raju.M
|
|
|
|
|
thanks for Helping me.
i pasted the code in Page load and it is working fine. but page load call this code on each event call. So is it good things to call and fatch record from database for creating table/grid? again and again for same page?
|
|
|
|
|
for Dynamically created controls its good.its for avoid disappearing control in PlaceHolder after postback.
Raju.M
|
|
|
|
|
Hello everyone, I am creating a page with various languages using ASP_Local_resources files, and it works correctly the user is able of choosing the language, but my problem is that in the language change it needs refresh all the screen not only located controls, and the page contains some graphics which make the language change a not very nice repainting, so I am thinking about Ajax in order to change only the afected controls, but I don´t know how to mixture the resources utilization and Ajax, could anybody give me a solution or any link in relation with.
Best Regards
|
|
|
|
|
I'm trying to load multiple images into a GridView from a SQL database based on a UserId. I was only able to get single images to load into a Image box.
On my page "ChangeProfile.aspx" I have:
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
On the code-behind page (in the Page_Load event) I have:
If Not Page.IsPostBack Then
Dim currentUser As MembershipUser = Membership.GetUser
Dim currentUserID As Guid
If Request.QueryString("Id") Is Nothing Then
currentUserID = CType(currentUser.ProviderUserKey, Guid)
Else
currentUserID = New Guid(Request.QueryString("Id"))
End If
Dim connectionString As String = ConfigurationManager.ConnectionStrings("SecurityTutorialsConnectionString").ConnectionString
'Dim insertSql As String = "UPDATE UserProfiles SET MainImage=@Content WHERE UserID=@UserId"
Dim stream As New MemoryStream
Using myConnection As New SqlConnection
myConnection.ConnectionString = connectionString
Dim myCommand As New SqlCommand("SELECT UploadedImage FROM Images WHERE UserId=@UserId", myConnection)
myCommand.Parameters.AddWithValue("@UserId", currentUserID)
Dim ds As New DataSet
Dim Adapter As New SqlDataAdapter(myCommand)
Adapter.Fill(ds)
GridView1.DataSource = ds
GridView1.DataBind()
End Using
End Sub
The table is it trying to pull from ("Images") has the following fields:
ImageId (Guid)
UserId (Guid)
UploadedImage (Image)
ImageDescription (nvarchar(MAX))
The error occurs at the GridView1.DataBind() with the following message:
"The data source for GridView with id 'GridView1' did not have any properties or attributes from which to generate columns. Ensure that your data source has content."
When I look at the table data there are two rows for the supplied UserId (hence two images). I've been working on this for 3 hours straight and cannot figure it out. Any help would be greatly appreciated.
|
|
|
|
|
You need to have more than just this
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
Where is the rest of it? Where are the columns?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Sorry...copied it before I had finished it:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns ="false">
<Columns>
<asp:ImageField ></asp:ImageField>
</Columns>
</asp:GridView>
I just can't figure out how to format the ImageField to display the images bound to the datagrid.
|
|
|
|
|
|
That is exactly what I needed. Thanks everyone!
|
|
|
|
|
use THIS
may be helps you.
Rating always..... WELCOME
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Hi,
I have vs2008/dotnet3.5 installed on my system(Winxp sp2). If i run a web application with dotnet framework 3.5, it gives the error 'compiler executable file csc.exe cannot be found'. If i change the dotnet frmwork from proj properties, the build is successful. But i need to run the app under framework 3.5. Any soulution of the above error.
Thanks in advance.
Saf
|
|
|
|
|
|
It happens on some machines with XP, Vista but does not on others.
Web site installer simply interrupts. In msiexec log those strings happen. What is the reason of aspnet_regiis.exe failure?
...
INFO : [07/03/2010 01:49:34:109] [GatherWebFolderProperties ]: Opening key '/LM/W3SVC/1/ROOT/MyWebSite/bin'.
ERROR : [07/03/2010 01:49:34:109] [GatherWebFolderProperties ]: Open failed.
...
INFO : [07/03/2010 01:49:34:765] [RegisterAspNet ]: Running process 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe' with parameters ' -norestart -sn "W3SVC/1/Root/MyWebSite"' silently...
INFO : [07/03/2010 01:49:34:828] [RegisterAspNet ]: Process Call Result Code: '0' Process Exit Code: '3'.
ERROR : [07/03/2010 01:49:34:843] [RegisterAspNet ]: The error indicates that this version of ASP.NET must first be registered on the machine.
...
...
=== Logging stopped: 2010/07/03 1:49:37 ===
MSI (c) (44:84) [01:49:37:125]: Note: 1: 1708
MSI (c) (44:84) [01:49:37:125]: Note: 1: 2262 2: Error 3: -2147287038
MSI (c) (44:84) [01:49:37:125]: Note: 1: 2262 2: Error 3: -2147287038
MSI (c) (44:84) [01:49:37:125]: Product: My Web Site -- Installation failed.
MSI (c) (44:84) [01:49:37:125]: Grabbed execution mutex.
MSI (c) (44:84) [01:49:37:125]: Cleaning up uninstalled install packages, if any exist
MSI (c) (44:84) [01:49:37:125]: MainEngineThread is returning 1603
=== Verbose logging stopped: 2010/07/03 1:49:37 ===
Чесноков
modified on Saturday, July 3, 2010 1:31 AM
|
|
|
|
|
Chesnokov Yuriy wrote: The error indicates that this version of ASP.NET must first be registered on the machine.
It's quite self explainatory. Go to Visual Studio Command Prompt and do this:
Step 1:
aspnet_regiis -u
Step 2:
aspnet_regiis -i
Step 3:
Now try to deploy/use installer.
If you are unable to find the utility 'aspnet_regiis', try at this location (as per your error log):
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\
|
|
|
|
|
Check if the target .NET framework version is installed on the server/machine where you are tying to deploy the web application. It might be possible that the target .NET framework version is not installed on that machine. If that is the case then install the required framework using the redistributable and proceed with the website installation.
If the target .NET framework is installed then, check if the target framework's ASP.NET libraries are registered on the machine/server's IIS. If not then register the ASP.NET libraries using aspnet_regiis of the respective framework. Check the tool's documentation @ ASP.NET IIS Registration Tool (Aspnet_regiis.exe)[^]
If the required .NET framework is installed and ASP.NET libraries are registered in IIS and still this error is thrown then check the default version of .NET framework that is configured in IIS. If it is not the desired version then create the necessary virtual directories / websites and set the target .NET framework manually and then proceed with the website install. Ensure that you use the new virtual directories / website for the installation.
HTH!
|
|
|
|
|
I have a DropDownList which is specified in the Triggers section of an UpdatePanel. However, I still have to set AutoPostBack=True on the DropDownList to get it to trigger a postback. Is this normal behavior? It seems to me if the DropDownList is specified as a trigger, you shouldn't have to deal with the AutoPostBack attribute.
|
|
|
|
|
Lonnie Raffray wrote: Is this normal behavior?
Yes! Normal behaviour it is.
Lonnie Raffray wrote: It seems to me if the DropDownList is specified as a trigger, you shouldn't have to deal with the AutoPostBack attribute
No. Triggers are indicators to Update Panel of how they need to react to a certain postback/update.
If implemented as you say, then AutoPostback property would have no use at all when used with a control placed in a UpdatePanel and why would anyone want to create such situation where a certain property's value is of no use! Ignoring that attribute would make no sense and create confusion.
If needed, read about triggers and update panel behaviour here:
UpdatePanel.Triggers Property [^]
UpdatePanel Control Overview[^]
|
|
|
|
|
While developing Web based software application using Software as a Service model which is the best option for development whether to go with ASP.Net or PHP
I'm experience with ASP.net but are there any issues implementing in ASP.Net
|
|
|
|