Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Saturday, March 31, 2012

Set a custom object property in a user control

hi, i have a user control that have a property MyProp of type MyObject.

MyObject also have a property named Prop1;

I want to set Prop1 in the aspx.

For example

<User:MyControl id="control>

<MyProp Prop1="value" />

</User:MyControl>

and

public class MyObject

{

public string Prop1 {get; set;}

}

This code works but i can't go to Design View becouse contents isn't allowed between openin and closing tag of an user control)

Somebody have a solution? ( i don't ant to change my user Control to a server control)

thanks

You cant have content between opening and closing tags.

Your code should be like as below:

<User:MyControl id="control"

Prop1="value">

</User:MyControl>

Try this and let me know if any issues


thanks for your reply but i don't need to set a property of my control, i need to set some properties of an object returned by a property of my control and

i neither want to remap all this properties to some new properties of the control becouse are too match;

a better example is (some implementation details are hidden):

class User

{

public string Name { set; }

public string Surname {set;}

}

class UserView : UserControl

{

public User TargetUser {get;}

}

and in the page

<MyControls:UserView id="userView1">

<TargetUser Name="sam" Surname="foofoo" />

</MyControls:UserView>

This code works but i can't switch to DesignView becouse Visual Studio see contents into my control tags.

I want know if there's a way to set Name and Value property of internal User object into the aspx without problems with visual studio parser.


Set a default property in a user control?

I'm not even sure if what I'm doing is possible. I created a simple control
that will be reused throughout the site. It will accept a large amount of
HTML with bulleted lists, etc
I want to implement like:
<uc1:KeyFeatures id="KeyFeatures1" runat="server">
Large amount of Inner Html content goes here between tags...
</uc1:KeyFeatures>
Not like:
<uc1:KeyFeatures id="KeyFeatures1" runat="server" InnerHtml="Large amount of
Inner Html content goes here between tags..."></uc1:KeyFeatures>
Can I do it this way? If so, is this considered the 'default' property and h
ow do I declare this in my uc so it accepts the text between the tags?
The code is below..this is a stripped down version.
public class KeyFeatures : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.Label lblInnerHtml;
public string InnerHtml
{
set
{
lblInnerHtml.Text = value;
}
}If you find can you please tell here how you do?
Iyigun
"Dave" <anonymous@.discussions.microsoft.com> wrote in message
news:243F1108-1CB3-4F93-8386-BE39FC3601CA@.microsoft.com...
> I'm not even sure if what I'm doing is possible. I created a simple
control that will be reused throughout the site. It will accept a large
amount of HTML with bulleted lists, etc
> I want to implement like:
> <uc1:KeyFeatures id="KeyFeatures1" runat="server">
> Large amount of Inner Html content goes here between tags...
> </uc1:KeyFeatures>
> Not like:
> <uc1:KeyFeatures id="KeyFeatures1" runat="server" InnerHtml="Large amount
of Inner Html content goes here between tags..."></uc1:KeyFeatures>
> Can I do it this way? If so, is this considered the 'default' property and
how do I declare this in my uc so it accepts the text between the tags?
> The code is below..this is a stripped down version.
> public class KeyFeatures : System.Web.UI.UserControl
> {
> protected System.Web.UI.WebControls.Label lblInnerHtml;
> public string InnerHtml
> {
> set
> {
> lblInnerHtml.Text = value;
> }
> }
>
>
>
>
>

Set a default property in a user control?

I'm not even sure if what I'm doing is possible. I created a simple control that will be reused throughout the site. It will accept a large amount of HTML with bulleted lists, et

I want to implement like

<uc1:KeyFeatures id="KeyFeatures1" runat="server"
Large amount of Inner Html content goes here between tags..
</uc1:KeyFeatures

Not like

<uc1:KeyFeatures id="KeyFeatures1" runat="server" InnerHtml="Large amount of Inner Html content goes here between tags..."></uc1:KeyFeatures

Can I do it this way? If so, is this considered the 'default' property and how do I declare this in my uc so it accepts the text between the tags?

The code is below..this is a stripped down version.

public class KeyFeatures : System.Web.UI.UserContro

protected System.Web.UI.WebControls.Label lblInnerHtml

public string InnerHtml

se

lblInnerHtml.Text = value
If you find can you please tell here how you do?
Iyigun

"Dave" <anonymous@.discussions.microsoft.com> wrote in message
news:243F1108-1CB3-4F93-8386-BE39FC3601CA@.microsoft.com...
> I'm not even sure if what I'm doing is possible. I created a simple
control that will be reused throughout the site. It will accept a large
amount of HTML with bulleted lists, etc
> I want to implement like:
> <uc1:KeyFeatures id="KeyFeatures1" runat="server">
> Large amount of Inner Html content goes here between tags...
> </uc1:KeyFeatures>
> Not like:
> <uc1:KeyFeatures id="KeyFeatures1" runat="server" InnerHtml="Large amount
of Inner Html content goes here between tags..."></uc1:KeyFeatures>
> Can I do it this way? If so, is this considered the 'default' property and
how do I declare this in my uc so it accepts the text between the tags?
> The code is below..this is a stripped down version.
> public class KeyFeatures : System.Web.UI.UserControl
> {
> protected System.Web.UI.WebControls.Label lblInnerHtml;
> public string InnerHtml
> {
> set
> {
> lblInnerHtml.Text = value;
> }
> }
>
>
>

Set bold, italic, font type etc on the textbox(multiple)?

I have problem to find the code to bold, italic, get the font type or set the size of font on the texbox. i develop forum site. when user want to send message, they need to fulfill the title and content. what i want to do same like in hotmail.com (the flexible textbox when to submit message). ThanksHi, seethis site.

Set border width for datagrid

Guys,
I have a dropdown and want the user to toggle border width or alternating
color etc for datagrid.
How can i implement this in codebehind?
Thanks
MannyUse the property AlternatingItemStyle
Cheers,
Gaurav Vaish
http://mastergaurav.org
--

set browser window size

I am trying to display my form in a fixed browser window so the user cannot change it's size, cannot minimize/maximize the window. The aspx form is for user input, and I want each user to see the same thing. (it's an internal form and everyone has the same browser). Where do I make these changes, or what code do I need? I figured it would be in the properties menu for the form, but the page margins do not make the changes I need. Any ideas on what to do?

Thanks.You can set thewindow properties from the client (i.e. note, no "runat" attribute in the script tag), only after the first page is loaded:

<SCRIPT for="window" event="onload">
window.dialogHeight = 100;
window.dialogLeft = 100;
window.dialogTop = 100;
window.dialogWidth = 100;
</SCRIPT>

Thursday, March 29, 2012

Set Conditional AutoPostBack In User Control

Assume that a user control has a TextBox (Page1.ascx)

<asp:TextBox ID="txtName" runat="server"/>

I am encapsulating the above user control in a ASPX page named
Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
CheckBox in this ASPX page within the <formtags. Note that the
CheckBox IS NOT a part of the user control. It has been explicitly
added to the Form existing in the ASPX page. The AutoPostBack property
of the CheckBox is set to True so that whenever the CheckBox is
checked/unchecked by the user, a sub named 'chk_Check' gets executed.
This is the ASPX code:

<%@dotnet.itags.org. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
........
........
End Sub
</script>

<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>

When the page loads for the first time, the CheckBox is unchecked by
default. Now what I want is if the CheckBox is checked by the user,
then the AutoPostBack property of the TextBox existing in the user
control (whose ID is txtName) should be set to True. If the CheckBox is
unchecked by the user, then the AutoPostBack property of the TextBox
named txtName in the user control should be set to False.

One way of doing this is to make use of a Session variable...something
like this (in the ASPX page):

Sub Page_Load(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub

Sub chk_Check(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub

& then in the ASCX page

<script runat="server">
Sub Page_Load(.....)
If (Session("chk") = 1) Then
txtName.AutoPostBack = True
Else
txtName.AutoPostBack = False
End If
End Sub
</script>

Are there any other ways to accomplish this logic since, as far as
possible, I would like to avoid using Session variables?

Moreover, are there any major drawbacks of the above logic? Of course,
one of them being Session variables are memory resident & another being
users' browser should have cookies enabled although on most occasions,
cookies remain enabled.If you want to do this as simply as possible, you will have the checkbox
auto postback to set the value. If you want this fully dynamic, you will
have to write JavaScript that creates a postback event on the textbox and
removes it via checking/unchecking the box.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/
*************************************************
Think Outside the Box!
*************************************************
<rn5a@.rediffmail.comwrote in message
news:1160321009.138108.22940@.c28g2000cwb.googlegro ups.com...

Quote:

Originally Posted by

Assume that a user control has a TextBox (Page1.ascx)
>
<asp:TextBox ID="txtName" runat="server"/>
>
I am encapsulating the above user control in a ASPX page named
Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
CheckBox in this ASPX page within the <formtags. Note that the
CheckBox IS NOT a part of the user control. It has been explicitly
added to the Form existing in the ASPX page. The AutoPostBack property
of the CheckBox is set to True so that whenever the CheckBox is
checked/unchecked by the user, a sub named 'chk_Check' gets executed.
This is the ASPX code:
>
<%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
........
........
End Sub
</script>
>
<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>
>
When the page loads for the first time, the CheckBox is unchecked by
default. Now what I want is if the CheckBox is checked by the user,
then the AutoPostBack property of the TextBox existing in the user
control (whose ID is txtName) should be set to True. If the CheckBox is
unchecked by the user, then the AutoPostBack property of the TextBox
named txtName in the user control should be set to False.
>
One way of doing this is to make use of a Session variable...something
like this (in the ASPX page):
>
Sub Page_Load(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
>
Sub chk_Check(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
>
& then in the ASCX page
>
<script runat="server">
Sub Page_Load(.....)
If (Session("chk") = 1) Then
txtName.AutoPostBack = True
Else
txtName.AutoPostBack = False
End If
End Sub
</script>
>
Are there any other ways to accomplish this logic since, as far as
possible, I would like to avoid using Session variables?
>
Moreover, are there any major drawbacks of the above logic? Of course,
one of them being Session variables are memory resident & another being
users' browser should have cookies enabled although on most occasions,
cookies remain enabled.
>


It's simple (i am assuming you want to use postbacks instead of dynamic
javascript). Just create a property for user control that will expose
autopostback for the text box as shown below (i defined it in code behind of
the user control)

Public Class Page1
Inherits System.Web.UI.UserControl

Public Property TextBoxAutoPostBack() As Boolean
Get
Return txtName.AutoPostBack
End Get
Set(ByVal value As Boolean)
txtName.AutoPostBack = value
End Set
End Property

End Class

Now use it in aspx page like this

<%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
mpc.TextBoxAutoPostBack = CType(obj, CheckBox).Checked
End Sub
</script>

<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>

Autopostback is serialized to viewstate by default so you page contains it
between postbacks. That's all.

Hope this helps
--

Milosz Skalecki
MCP, MCAD

"rn5a@.rediffmail.com" wrote:

Quote:

Originally Posted by

Assume that a user control has a TextBox (Page1.ascx)
>
<asp:TextBox ID="txtName" runat="server"/>
>
I am encapsulating the above user control in a ASPX page named
Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
CheckBox in this ASPX page within the <formtags. Note that the
CheckBox IS NOT a part of the user control. It has been explicitly
added to the Form existing in the ASPX page. The AutoPostBack property
of the CheckBox is set to True so that whenever the CheckBox is
checked/unchecked by the user, a sub named 'chk_Check' gets executed.
This is the ASPX code:
>
<%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
........
........
End Sub
</script>
>
<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>
>
When the page loads for the first time, the CheckBox is unchecked by
default. Now what I want is if the CheckBox is checked by the user,
then the AutoPostBack property of the TextBox existing in the user
control (whose ID is txtName) should be set to True. If the CheckBox is
unchecked by the user, then the AutoPostBack property of the TextBox
named txtName in the user control should be set to False.
>
One way of doing this is to make use of a Session variable...something
like this (in the ASPX page):
>
Sub Page_Load(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
>
Sub chk_Check(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
>
& then in the ASCX page
>
<script runat="server">
Sub Page_Load(.....)
If (Session("chk") = 1) Then
txtName.AutoPostBack = True
Else
txtName.AutoPostBack = False
End If
End Sub
</script>
>
Are there any other ways to accomplish this logic since, as far as
possible, I would like to avoid using Session variables?
>
Moreover, are there any major drawbacks of the above logic? Of course,
one of them being Session variables are memory resident & another being
users' browser should have cookies enabled although on most occasions,
cookies remain enabled.
>
>

Set Conditional AutoPostBack In User Control

Assume that a user control has a TextBox (Page1.ascx)
<asp:TextBox ID="txtName" runat="server"/>
I am encapsulating the above user control in a ASPX page named
Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
CheckBox in this ASPX page within the <form> tags. Note that the
CheckBox IS NOT a part of the user control. It has been explicitly
added to the Form existing in the ASPX page. The AutoPostBack property
of the CheckBox is set to True so that whenever the CheckBox is
checked/unchecked by the user, a sub named 'chk_Check' gets executed.
This is the ASPX code:
<%@dotnet.itags.org. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
.......
.......
End Sub
</script>
<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>
When the page loads for the first time, the CheckBox is unchecked by
default. Now what I want is if the CheckBox is checked by the user,
then the AutoPostBack property of the TextBox existing in the user
control (whose ID is txtName) should be set to True. If the CheckBox is
unchecked by the user, then the AutoPostBack property of the TextBox
named txtName in the user control should be set to False.
One way of doing this is to make use of a Session variable...something
like this (in the ASPX page):
Sub Page_Load(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
Sub chk_Check(.....)
If (chk1.Checked = True) Then
Session("chk") = 1
Else
Session("chk") = 0
End If
End Sub
& then in the ASCX page
<script runat="server">
Sub Page_Load(.....)
If (Session("chk") = 1) Then
txtName.AutoPostBack = True
Else
txtName.AutoPostBack = False
End If
End Sub
</script>
Are there any other ways to accomplish this logic since, as far as
possible, I would like to avoid using Session variables?
Moreover, are there any major drawbacks of the above logic? Of course,
one of them being Session variables are memory resident & another being
users' browser should have cookies enabled although on most occasions,
cookies remain enabled.If you want to do this as simply as possible, you will have the checkbox
auto postback to set the value. If you want this fully dynamic, you will
have to write JavaScript that creates a postback event on the textbox and
removes it via checking/unchecking the box.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/
****************************************
*********
Think Outside the Box!
****************************************
*********
<rn5a@.rediffmail.com> wrote in message
news:1160321009.138108.22940@.c28g2000cwb.googlegroups.com...
> Assume that a user control has a TextBox (Page1.ascx)
> <asp:TextBox ID="txtName" runat="server"/>
> I am encapsulating the above user control in a ASPX page named
> Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
> CheckBox in this ASPX page within the <form> tags. Note that the
> CheckBox IS NOT a part of the user control. It has been explicitly
> added to the Form existing in the ASPX page. The AutoPostBack property
> of the CheckBox is set to True so that whenever the CheckBox is
> checked/unchecked by the user, a sub named 'chk_Check' gets executed.
> This is the ASPX code:
> <%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
> <script runat="server">
> Sub chk_Check(obj As Object, ea As EventArgs)
> ........
> ........
> End Sub
> </script>
> <form runat="server">
> <MyPage:Ctrl ID="mpc" runat="server"/><br>
> <asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
> AutoPostBack="true" Text="Check Me" runat="server"/>
> </form>
> When the page loads for the first time, the CheckBox is unchecked by
> default. Now what I want is if the CheckBox is checked by the user,
> then the AutoPostBack property of the TextBox existing in the user
> control (whose ID is txtName) should be set to True. If the CheckBox is
> unchecked by the user, then the AutoPostBack property of the TextBox
> named txtName in the user control should be set to False.
> One way of doing this is to make use of a Session variable...something
> like this (in the ASPX page):
> Sub Page_Load(.....)
> If (chk1.Checked = True) Then
> Session("chk") = 1
> Else
> Session("chk") = 0
> End If
> End Sub
> Sub chk_Check(.....)
> If (chk1.Checked = True) Then
> Session("chk") = 1
> Else
> Session("chk") = 0
> End If
> End Sub
> & then in the ASCX page
> <script runat="server">
> Sub Page_Load(.....)
> If (Session("chk") = 1) Then
> txtName.AutoPostBack = True
> Else
> txtName.AutoPostBack = False
> End If
> End Sub
> </script>
> Are there any other ways to accomplish this logic since, as far as
> possible, I would like to avoid using Session variables?
> Moreover, are there any major drawbacks of the above logic? Of course,
> one of them being Session variables are memory resident & another being
> users' browser should have cookies enabled although on most occasions,
> cookies remain enabled.
>
It's simple (i am assuming you want to use postbacks instead of dynamic
javascript). Just create a property for user control that will expose
autopostback for the text box as shown below (i defined it in code behind of
the user control)
Public Class Page1
Inherits System.Web.UI.UserControl
Public Property TextBoxAutoPostBack() As Boolean
Get
Return txtName.AutoPostBack
End Get
Set(ByVal value As Boolean)
txtName.AutoPostBack = value
End Set
End Property
End Class
Now use it in aspx page like this
<%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
<script runat="server">
Sub chk_Check(obj As Object, ea As EventArgs)
mpc.TextBoxAutoPostBack = CType(obj, CheckBox).Checked
End Sub
</script>
<form runat="server">
<MyPage:Ctrl ID="mpc" runat="server"/><br>
<asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
AutoPostBack="true" Text="Check Me" runat="server"/>
</form>
Autopostback is serialized to viewstate by default so you page contains it
between postbacks. That's all.
Hope this helps
--
Milosz Skalecki
MCP, MCAD
"rn5a@.rediffmail.com" wrote:

> Assume that a user control has a TextBox (Page1.ascx)
> <asp:TextBox ID="txtName" runat="server"/>
> I am encapsulating the above user control in a ASPX page named
> Page1.aspx i.e. the ASPX page displays a single TextBox. There's also a
> CheckBox in this ASPX page within the <form> tags. Note that the
> CheckBox IS NOT a part of the user control. It has been explicitly
> added to the Form existing in the ASPX page. The AutoPostBack property
> of the CheckBox is set to True so that whenever the CheckBox is
> checked/unchecked by the user, a sub named 'chk_Check' gets executed.
> This is the ASPX code:
> <%@. Register TagPrefix="MyPage" TagName="Ctrl" src="http://pics.10026.com/?src=Page1.ascx" %>
> <script runat="server">
> Sub chk_Check(obj As Object, ea As EventArgs)
> ........
> ........
> End Sub
> </script>
> <form runat="server">
> <MyPage:Ctrl ID="mpc" runat="server"/><br>
> <asp:CheckBox ID="chk1" OnCheckedChanged="chk_Check"
> AutoPostBack="true" Text="Check Me" runat="server"/>
> </form>
> When the page loads for the first time, the CheckBox is unchecked by
> default. Now what I want is if the CheckBox is checked by the user,
> then the AutoPostBack property of the TextBox existing in the user
> control (whose ID is txtName) should be set to True. If the CheckBox is
> unchecked by the user, then the AutoPostBack property of the TextBox
> named txtName in the user control should be set to False.
> One way of doing this is to make use of a Session variable...something
> like this (in the ASPX page):
> Sub Page_Load(.....)
> If (chk1.Checked = True) Then
> Session("chk") = 1
> Else
> Session("chk") = 0
> End If
> End Sub
> Sub chk_Check(.....)
> If (chk1.Checked = True) Then
> Session("chk") = 1
> Else
> Session("chk") = 0
> End If
> End Sub
> & then in the ASCX page
> <script runat="server">
> Sub Page_Load(.....)
> If (Session("chk") = 1) Then
> txtName.AutoPostBack = True
> Else
> txtName.AutoPostBack = False
> End If
> End Sub
> </script>
> Are there any other ways to accomplish this logic since, as far as
> possible, I would like to avoid using Session variables?
> Moreover, are there any major drawbacks of the above logic? Of course,
> one of them being Session variables are memory resident & another being
> users' browser should have cookies enabled although on most occasions,
> cookies remain enabled.
>

Set datagrid cell enabled to false

When a user hits the edit button, I want to either make a certain cell not enabled, or not visible. I don't care which. I can't seem to get either to work.

Here is my code that I tried:Dim cn As New OleDb.OleDbConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;" _
& "Persist Security Info=False;" _
& "Initial Catalog=fuel info;" _
& "UID=;PWD=;" _
& "Data Source=Server7")
cn.Open()

Dim datAdapt As New OleDb.OleDbDataAdapter("Select Vendor_No as [Vendor No], " & _
"Vendor_Name as [Vendor Name], Vendor_Terminal as [Vendor Terminal], " & _
"Vendor_Trmnl_No As [Terminal No], Vendor_City As [City], Vendor_State As " & _
"[State], ID From Other_Vendors Order By Vendor_Name", cn)

Dim datSet As New Data.DataSet

datAdapt.Fill(datSet, "Other_Vendors")

DataGrid1.DataSource = datSet
DataGrid1.DataKeyField = "ID"
DataGrid1.EditItemIndex = e.Item.ItemIndex
e.Item.Cells(3).Enabled = False
DataGrid1.DataBind()
cn.Close()
cn.Dispose()
datAdapt.Dispose()
datSet.Dispose()
As you can see, the line that is not working is "e.item.cells(3).enabled = false"

Also, if anyone knows how to set the width of the cell on the fly as well, I would appreciate that as well.

ThanksTry looking into the ItemDataBound sub and adding

e.Item.Cells(3).Enabled = False

in there. You cant disable the cells before the data is in them. RIght now you are trying to disable that cell before the data has been bound to the grid.

Jerel
Phelnglai, that did the trick. One more quick question. Could you set the cell width from the same place? If so, do you know the syntax? Thanks.

What about the cell header? What would the syntax be for that?

Thanks again!
Nevermind, I see that if you just increase the width of the actual datagrid, the fields will increase and adjust on their own at run time.
Glad you got it. Sorry I never answered your second question. I was in a car wreck and am just now getting back to work and doing thinks.

If you have any other questions, feel free to ask.

Jerel

Wednesday, March 28, 2012

Set default button

How can I set a button as default on an aspx page? When the user hits the
Enter button this default button is automtcally clicked.
Thanks,
LouIn ASP.NET 2.0 the panel control has a new DefaultButton property.
Set this property to the ID of a button control and it will be the default
button when focus is in that panel.
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Lou Civitella" <lou@.webersystems.com> wrote in message
news:ucBQh8$PHHA.4492@.TK2MSFTNGP02.phx.gbl...
> How can I set a button as default on an aspx page? When the user hits the
> Enter button this default button is automtcally clicked.
> Thanks,
> Lou
>
Hi,
To your TextBox add a JavaScript event onkeydown using
Attributes.Add().
if pressed key is EnterKey i.e with KeyCode=13 then call the Click()
method of the button(this is the default button)
TextBox1.Attributes.Add("onkeydown", "if(event.keyCode){if
(event.keyCode == 13)
{document.getElementById('"+Button1.UniqueID+"').click();return
false;}} else {return true}; ");
thanks,
aru

Set default button

How can I set a button as default on an aspx page? When the user hits the
Enter button this default button is automtcally clicked.

Thanks,
LouIn ASP.NET 2.0 the panel control has a new DefaultButton property.
Set this property to the ID of a button control and it will be the default
button when focus is in that panel.

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Lou Civitella" <lou@.webersystems.comwrote in message
news:ucBQh8$PHHA.4492@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

How can I set a button as default on an aspx page? When the user hits the
Enter button this default button is automtcally clicked.
>
Thanks,
Lou
>


Hi,

To your TextBox add a JavaScript event onkeydown using
Attributes.Add().
if pressed key is EnterKey i.e with KeyCode=13 then call the Click()
method of the button(this is the default button)

TextBox1.Attributes.Add("onkeydown", "if(event.keyCode){if
(event.keyCode == 13)
{document.getElementById('"+Button1.UniqueID+"').click();return
false;}} else {return true}; ");

thanks,
aru

Set default button pressed when the user press the return key

Hi

ive got a textbox and a button on a page. I want it so whenever the user types something in the textbox and then press their return key, the form button gets pressed.

How do i do that? set which button gets pressed when the user press the 'return/enter' key on their keyboard.

how someone can help

thanks

Check out this post for 3 great ways to make a button the default:

http://forums.asp.net/thread/1671669.aspx

Monday, March 26, 2012

set default login name

i want to set the default login name for user, i.e. each time the user use
the application, the login name would be displayed in advance and user only
need to input the password. how to do that'
million thanks..That depends, is this user creating an account.
Does the username exists already.
Is the username the same for all users or different for each user.
I'm assuming that the user has already got an account, and returning to the
site.
The way you can make the site remember a user is with cookies.
You set the cookie when the user logs in. Then whenever the page loads, it
looks of that cookie exists and if so, sets the users username in the
username textbox
"Grey" <erickwyum@.i-cable.com> wrote in message
news:%234sQC77nEHA.2808@.TK2MSFTNGP10.phx.gbl...
>i want to set the default login name for user, i.e. each time the user use
> the application, the login name would be displayed in advance and user
> only
> need to input the password. how to do that'
> million thanks..
>

Set Default value for a Property in a user defined class

Hello,
I have created a class in vb .net and would like to add a property tothis class with a default value. The purpose of this would bethat if the user didn't supply a value for the property (or evenreference the property) it would contain the default value. Forexample here is what I have tried:
Public Shared MultipleResults As Boolean = False
My pages don't work properly as the property doesn't seem to be set to False.
Thanks in advance,
Paul Liadis
Penn State University
What do you mean by "pages don't work properly"? Do they crash or are you just not getting the results you expect?
An uninitialized Boolean will return False (which is ambiguous, of course). For example:
Class Test
Public Shared MultipleResults As Boolean = False
Public Shared MultipleResultsUnInit As Boolean
End Class
Sub Button1_Click(sender As Object, e As EventArgs)
Dim t As New Test
Response.Write("<br>Value = " & t.MultipleResults)
Response.Write("<br>Value = " & t.MultipleResultsUnInit)
End Sub

When I run this, I get False for both properties.
Are you perhaps running into the issue that the property value is not being persisted across postbacks?


Sorry about the vague statement "doesn't work". The pages do notcrash. They give results that I did not expect. Here is avery small version of the example you gave, with slight midifications:
Class Test
Public Shared globalCustomColumnWidths As Boolean = False
' many other subroutines and such here
shared sub ASubroutine()
If globalCustomColumnWidths = False Then
TableCellObj.Width = Unit.Percentage(25)
Else
TableCellObj.Width = Unit.Percentage(globalWidthArray(0))
End If
end sub
End Class
What I would like to happen is that when I call my test class, I would like for globalCustomerColumnWidths to
evaluate to false, even if I don't set it to anything. This doesn't seem to be happening. Any thoughts? Also,
what did you mean by "An uninitialized Boolean will return False (which is ambiguous, of course)."?
Thanks for the response.



Sorry, I'm not understanding the relationship between globalCustomColumnWidths and MultipleResults. (?)
>"ambiguous, of course"
That if an uninitialized Boolean returns false, you don't know whether it's uninitialized or has been explicitly set to false.

Set field to null

I am trying to set a field in a sql server table to null if the user hits a certain button.

How can I set it to DBNull?

I have tried the following but It doesnt work.

Dim updateSOrder As String = "Update SOrders set confirm_id = @dotnet.itags.org.confirmId where SOrder ='" & lblConfirmOrder.Text & "'"

Dim SaveDelete As SqlCommand
SaveDelete = New SqlCommand(updateSOrder, oConnection)

Dim blank As DBNull
SaveDelete.Parameters.Add(New SqlParameter("@dotnet.itags.org.ConfirmId", SqlDbType.NVarChar, 40))
SaveDelete.Parameters("@dotnet.itags.org.ConfirmId").Value = blank

SaveDelete.ExecuteNonQuery()

You may try this:

SaveDelete.Parameters("@.ConfirmId").Value = DBNull.Value

Set filename in IE Save As dialog for download file?

Hi,

I store attachment file in SQL Server database and user can download it
later by using a download page e.g. Download.aspx?FileID=1234, the problem
is Internet Explorer always show default filename is "Download.aspx" in it's
"Save As" dialog box, how can I force it to display original uploaded
filename (which I save in database too)?

thank you,Well, for example:

string disHeader = "Attachment; Filename=\"" + filename + "\"";
Response.AppendHeader("Content-Disposition", disHeader);
/C

Cristoffer Crusell
Use this code:
Response.AddHeader("Content-Disposition", "inline;filename=test.xls")

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Tien" <tiendq@.gmail.com> wrote in message
news:1d72a31c.0501212036.715c9971@.posting.google.c om...
> Hi,
> I store attachment file in SQL Server database and user can download it
> later by using a download page e.g. Download.aspx?FileID=1234, the problem
> is Internet Explorer always show default filename is "Download.aspx" in
> it's
> "Save As" dialog box, how can I force it to display original uploaded
> filename (which I save in database too)?
> thank you,

Set filename in IE Save As dialog for download file?

Hi,
I store attachment file in SQL Server database and user can download it
later by using a download page e.g. Download.aspx?FileID=1234, the problem
is Internet Explorer always show default filename is "Download.aspx" in it's
"Save As" dialog box, how can I force it to display original uploaded
filename (which I save in database too)?
thank you,Well, for example:
string disHeader = "Attachment; Filename=\"" + filename + "\"";
Response.AppendHeader("Content-Disposition", disHeader);
/C
Cristoffer Crusell
Use this code:
Response.AddHeader("Content-Disposition", "inline;filename=test.xls")
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Tien" <tiendq@.gmail.com> wrote in message
news:1d72a31c.0501212036.715c9971@.posting.google.com...
> Hi,
> I store attachment file in SQL Server database and user can download it
> later by using a download page e.g. Download.aspx?FileID=1234, the problem
> is Internet Explorer always show default filename is "Download.aspx" in
> it's
> "Save As" dialog box, how can I force it to display original uploaded
> filename (which I save in database too)?
> thank you,

Set Focus

When i load a form and the user selects an item from a dropdown list i want to set focus to another control. In standard vb and standard vb.net i can do this. Anyone know how to do this asp.net?... any help would be greatly appreciated

Thank youYou need to add some clientside JavaScript code in the form of an onchange event handler.
OTTOMH, something like:

DDL.attributes.add("onchange","document.getElementById('controlId').focus()")

Saturday, March 24, 2012

set focus after cancelling edit in gridview

Hi,
I have a gridview with edit option. If the user chooses to edit the
row and then press the Cancel button - I would like the focus to
return to the chosen row.
Someone has any idea how to implement it?
Thanks.
Regards,
Ruthie.ruthie wrote:
> Hi,
> I have a gridview with edit option. If the user chooses to edit the
> row and then press the Cancel button - I would like the focus to
> return to the chosen row.
> Someone has any idea how to implement it?
What do you mean by focus?
Riki
On Jun 10, 6:32 pm, "Riki" <r...@.dontnagme.com> wrote:
> ruthie wrote:
>
>
> What do you mean by focus?
> --
> Riki
Hi Riki,
Lets say that the user scrolls the gridview page and presses the edit
button and
then he chooses to cancel editing. After he presses the cancel button,
the page is
regenerated and he sees now the beginning of the page - and not the
row which he chose before.
I had the same problem with the edit button - but I managed to solve
it - After the user presses the edit button, there is a
radiobuttonlist in the chosen row
(edit template) - so I use this.setFocus(controlID) - but when
cancelling edit - all the rows are the same and there is no special
row.
Thanks so much.
Ruthie.
Jessica Alba and Sarah M. Gellar Lick Pussies On Sofa!
http://www.reyrewh.com/Player.wmv?q=1673286
Cameron Diaz and Mariah Carey Machine XXXX!
http://www.reyrewh.com/PlayFile?clip=1673286
Shania Twain and Angelina Jolie , Weird Lesbian Sex Act!
http://www.reyrewh.com/WindowsMedia...mpeg?q=1673286
Halle Berry and Lindsay Lohan Crazy On High Heels!
http://www.reyrewh.com/watch?id=1673286
Cameron Diaz and Christina Aguilera Hardest Lesbians Wrestling Match!
http://www.reyrewh.com/WatchMovie?watch=1673286
japanese sex moviefree sex clipanal pregnant sexadvice card consolidation credit debtlesbian sex site
http://yxss6yjt.t35.com/sex-video/s...-sex-video.htmlhttp://qrioullz.t35.com/adult-sex-t...oy
.htmlhttp://cteud0l4.t35.com/sex-picture...on-a-plane.htmlhttp://slw7p
l0p.t35.com/tee...e-teen-sex.htmlhttp://qrioullz.t35.com/adult-sex-t...me-sex-toy.html

set focus after cancelling edit in gridview

Hi,

I have a gridview with edit option. If the user chooses to edit the
row and then press the Cancel button - I would like the focus to
return to the chosen row.

Someone has any idea how to implement it?

Thanks.
Regards,

Ruthie.ruthie wrote:

Quote:

Originally Posted by

Hi,
>
I have a gridview with edit option. If the user chooses to edit the
row and then press the Cancel button - I would like the focus to
return to the chosen row.
>
Someone has any idea how to implement it?


What do you mean by focus?

--

Riki
On Jun 10, 6:32 pm, "Riki" <r...@.dontnagme.comwrote:

Quote:

Originally Posted by

ruthie wrote:

Quote:

Originally Posted by

Hi,


>

Quote:

Originally Posted by

I have a gridview with edit option. If the user chooses to edit the
row and then press the Cancel button - I would like the focus to
return to the chosen row.


>

Quote:

Originally Posted by

Someone has any idea how to implement it?


>
What do you mean by focus?
>
--
>
Riki


Hi Riki,

Lets say that the user scrolls the gridview page and presses the edit
button and
then he chooses to cancel editing. After he presses the cancel button,
the page is
regenerated and he sees now the beginning of the page - and not the
row which he chose before.
I had the same problem with the edit button - but I managed to solve
it - After the user presses the edit button, there is a
radiobuttonlist in the chosen row
(edit template) - so I use this.setFocus(controlID) - but when
cancelling edit - all the rows are the same and there is no special
row.

Thanks so much.
Ruthie.