|
First way would be to have the database query return only the column you are looking for.
Otherwise try this
DataTable EmployeeName = new DataTable();<br />
EmployeeName.Columns.Add("EmployeeName");<br />
EmployeeName.Merge(fullDataTable);
only two letters away from being an asset
|
|
|
|
|
Hi everybody.
Currently i'm developing a system in Visual Basic .NET under 1.1 Framework, that requires add a couple of webcontrols (mainly Buttons), and i need these controls to respond to events, like the Click one. Is very easy to do this to a control added to a project on design time. But if i want to add buttons on execution time, and that every button responds to a click doing something (something simple like raise a javascript message, or delete a database record) i get confused.
I tried using Button.Attributes.Add("onclick", "something-to-do") but this approach is not working at all.
I really apreciate if someone knows how to do this.
Kind regards,
Leistath.
"I hated myself... no, I hated my place in the world" - From Jerry Maguire
|
|
|
|
|
In vb.net use
<br />
'After you create your control<br />
AddHandler Button1.Click, AddressOf Button1_Click<br />
<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) <br />
<br />
'put your code here, it should fire on postback<br />
End Sub
I didn't get any requirements for the signature
|
|
|
|
|
Thank you ToddHileHoffer. I followed your suggestion and i get working this now. I really appreciate your help mate.
Regards,
leistath
"I hated myself... no, I hated my place in the world" - From Jerry Maguire
|
|
|
|
|
hi,
its Asp.net discussion forum. i think you are trying to use the asp.net method in the
vb.net.
you have to add some handlers for this.
eg.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler Me.Click, AddressOf form_click
End Sub
Sub form_click(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
This handler will be called when the form has been clicked.
Try this type and you can remove it
through
removehandler Me.Click, AddressOf form_click
All The Best
Sathesh Pandian
|
|
|
|
|
Thanks Sathesh, i've understood how this works. Thank you so much.
"My pain is constant and sharp...and i do not hope for better world for anyone. In fact, i want my pain to be inflicted on others..." - Children Of Bodom - Bodom Beach Terror
|
|
|
|
|
Hi all,
Some time before I was struggling with Page break. now I found the method for page break nad still finding to add columns headers after 15 rows.
I am using the following script to set up the page break after printing 15 items in a page. It is working all right. Is there any other way to insert page break after certain page margin?
protected void GVMaterialMovement_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
count++;
if(count > 15)
{
e.Row.Style.Add("page-break-after", "always");
count = 0;
}
}
}
Is there any similar way to add header after each 15 Records?
Bajrang Singh
Using .net 2.0 (VS2005)
|
|
|
|
|
Hi there.
I am uploading images to my website and them writeing it into a DB. I want to do validation on the image that i upload. At the moment i am checking the size(bytes) of the image. what i also need to do, is check the Physical lenght of the image.
Can anyone help me with this?
Thanks
|
|
|
|
|
if(fileUpload1.HasFile == true)
{
blah blah...
}
Hope it helps
|
|
|
|
|
Try this.
<br />
<script runat="server"><br />
Sub submit(Sender as Object, e as EventArgs)<br />
fname.InnerHtml=MyFile.PostedFile.FileName<br />
clength.InnerHtml=MyFile.PostedFile.ContentLength<br />
End Sub<br />
</script><br />
<br />
<html><br />
<body><br />
<br />
<form id="Form1" method="post"<br />
enctype="multipart/form-data" runat="server"><br />
<p><br />
Select file to upload to server:<br />
<input id="MyFile" type="file" size="40" runat="server"> <br />
</p><br />
<p><br />
<input id="Submit1" type="submit" value="Upload!" OnServerclick="submit"<br />
runat="server"><br />
</p><br />
<p><br />
<div id="Div1" runat="server"><br />
FileName: <span id="fname" runat="server"/><br /><br />
ContentLength: <span id="clength" runat="server"/> bytes<br />
</div><br />
</p><br />
</form><br />
<br />
</body><br />
</html> <br />
<br />
Bajrang Singh
Using .net 2.0 (VS2005)
|
|
|
|
|
Can any one please tell me how to display messagebox on a button click using a server control.
Thanks in advance
|
|
|
|
|
Use Javascript to Display the Message Box
Regards,
Satips.
|
|
|
|
|
<script language="javascript" type="text/javascript">
function confirmation()
{
return window.confirm("Are sure u want to redirect");
}
</script>
If (Not Page.IsPostBack) Then
Button1.Attributes.Add("onclick", "javascript:return confirmation();")
End If
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("archana.aspx")
End Sub
Sonia Gupta
Soniagupta1@yahoo.co.in
|
|
|
|
|
I am not sure what programming language and what version of .net you are looking for. Here is an example in vb.net for .net 1.1
Private Sub ShowMessageBox(ByVal aMessage As String)
'This procedure will cause a dialog box to pop up with whatever message is passed in.
aMessage = aMessage.Replace(vbCrLf, "\n").Replace("""", "'")
Dim myScript As New StringBuilder
With myScript
.Append("<script>")
.Append(Environment.NewLine)
.Append("alert(""").Append(aMessage).Append(""");")
.Append(Environment.NewLine)
.Append("</script>")
Page.RegisterStartupScript("Promo Error", .ToString())
End With
End Sub
It is slightly different for .net 2.0 and the syntax is a little different for C#.
Hope that helps.
Ben
|
|
|
|
|
Thanks for all ur Replies. I will check your suggestions,
Im using dotnet2005 i.e version2.0 and vb.net as codebehind
|
|
|
|
|
In that case the code is slightly different:
Private Sub ShowMessageBox(ByVal aMessage As String)
'This procedure will cause a dialog box to pop up with whatever message is passed in.
aMessage = aMessage.Replace(vbCrLf, "\n").Replace("""", "'")
Dim myScript As New StringBuilder
With myScript
.Append("<script>")
.Append(Environment.NewLine)
.Append("alert(""").Append(aMessage).Append(""");")
.Append(Environment.NewLine)
.Append("</script>")
ClientScript.RegisterStartupScript(Me.GetType(), "Promo Error", .ToString())
End With
End Sub
Ben
|
|
|
|
|
is there any event that fires up when the web for is closed?
Sonia Gupta
Soniagupta1@yahoo.co.in
|
|
|
|
|
|
Hello Ben......
is there any other way out to check whether the fom is closing...
Sonia Gupta
Soniagupta1@yahoo.co.in
|
|
|
|
|
You can track browser close event
|
|
|
|
|
There are some things you can do with javascript, but nothing works all the time. I would guess you aren't interested in javascript you want something to happen on the server side like expire a session or something like that. There really isn't any good way of doing it. If you do a google search on browser closing event you will see some discussions on this and what other people have tried.
Ben
|
|
|
|
|
You must know the the life cycle of web from . It is stateless so is that possible to close web from . just u close the explore. The last event of web form is dispose. Ok .
Devjit
|
|
|
|
|
|
you can catch that event only using javascript.
All The Best
Sathesh Pandian
|
|
|
|
|
Hi,
Im a bit rusty with .Net so forgive my ignoarance.
I need the easiest (minimal code) way to count the number of records returned by a SqlDataSource (SQL2005). This can be either with a DataSet or a Reader.
Thanks
|
|
|
|