Updating button text when FormView item is Updated - asp.net

I'm still somewhat new to ASP, and can't seem to figure out what the issue is.
When I update an item in FormView, I need the text of a button to change.
I'm using:
Protected Sub fvClientInfo_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs) Handles fvClientInfo.ItemUpdated
btnEditClient.Text = "Edit"
End Sub
The line of code is being called (can tell from debug mode), but the button text isn't changing and I have no idea why.
I should make sure to mention that the button is NOT inside the FormView.
Any ideas?

Try this.
Protected Sub btnchange() Handles FormView1.DataBound
Button1.Text = "Newtxt"
End Sub
and add this to your formview
OnDataBound="btnchange"

Related

Losing custom gridview font when new page selected

I am using this code to change the font color in a grid view for a single column depending on value:
For Each row As GridViewRow In gvSearch.Rows
If row.Cells(8).Text.Trim = "Used" Then
row.Cells(8).CssClass = "CautionRow"
End If
Next
This code runs after the gridview databind. However, the gridview has pages available and this code only changes the first page of the grid view. I can resolve the problem by not allowing pages, but this is a tacky solution. Any suggetions?
Register PageIndexChanging event
onpageindexchanging="gvSearch_PageIndexChanging"
Then in event handler do your font changing logic like
Sub gvSearch_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
{
For Each row As GridViewRow In gvSearch.Rows
If row.Cells(8).Text.Trim = "Used" Then
row.Cells(8).CssClass = "CautionRow"
End If
Next
}
Actually found my own answer thanks to help from my fellow programmer. Here's what really works:
In the style sheet (.css) add this:
.CautionRow {
color: red;
}
... then add this to your code:
Protected Sub gvSearch_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViwRowEventArgs) Handles gvSearch.RowDatabound
If e.Row.Cells.Count > 1 Then
If e.Row.Cells(8).Text.ToString.ToLower.Trim = "used" Then
e.Row.Cells(8).CssClass = "CautionRow"
End If
End If
End Sub

I would like to trigger an event when a checkbox is clicked

Private Sub ShowPasswordButton_CheckedChanged(sender As Object, e As EventArgs) Handles ShowPasswordButton.CheckedChanged
If ShowPasswordButton.Checked = True Then
NewPassword.TextMode = TextBoxMode.SingleLine
Else
NewPassword.TextMode = TextBoxMode.Password
End If
End Sub
I am trying to change text appearance when the box is checked, but checking the box does nothing. It doesn't trigger the event at all. I have this placed in the right spot and I would assume that it should run, but it isn't.
You should have the AutoPostBack="True" property in your checkbox to trigger a server side event.

How to pass value from gridview inside modal pop up extender to textbox in parent form?

I tried to execute below codes to pass selected row value from gridview inside modal pop up extender to textbox in parent form but it doesn't work.
Private Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
txttitle.Text = GridView1.SelectedRow.Cells(1).Text
End Sub
Passing values from ajax popup (gridview) to parent page textbox.
This links help you.
http://mattberseth.com/blog/2008/04/masterdetail_with_the_gridview.html
http://mattberseth.com/blog/2007/07/modalpopupextender_example_for.html

asp.net masterpage - make hyperlink visible at runtime

Is it possible to alter the visible property of hyperlinks on a masterpage at runtime?
thanks
If you expose the hyperlink as a property on the master page, you can get a reference to a pages master and cast that to your specific master page then set visibility of the hyperlinks using that property.
In your master page have something like this:
Public ReadOnly Property RemitViewerLink() As HyperLink
Get
Return hlRemitViewer
End Get
End Property
Then in your child page you can do this
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim MyMaster As MasterPage = DirectCast(Page.Master, MasterPage)
MyMaster.RemitViewerLink.CssClass = "selectedMenuItem" 'or set visibility
End Sub
No, if you set visible=False then it won't even display in the HTML output of the page. You would need to use javascript to hide/show the hyperlinks instead.

Masterpage with Asp.net Ajax problem

I placed the scritmanager to masterpage. "scriptmanager1"
There is an updatepanel in the masterpage shows total. "updatepanel1"
In the contentpage I have nested listviews. the "listview2" inside the "listview1" has itemtemplate with a linkbutton called "addtoTotal"
I want to update the updatepanel1 inside the masterpage when user clicks to addtoTotal button.
updatepanel1's update mode is conditional.
How can I do this.
Firstly I could not findcontrol addtoTotal linkbutton.
Second how can I register this button to update updatepanel1
I want to triger the conditional updatepanel from the contentpage.
I tried to do something like this
protected void Page_Load(object sender, EventArgs e) { ScriptManager1.RegisterAsyncPostBackControl(myControl);
}
I could not. Because I don't know where to write this RegisterAsyncPostBackControl code. I could not findcontrol the linkbutton. I am not sure about the way I am trying to solve this is right way.
You can put a subroutine on your master page that updates the panel and you can call it from the content page like so.
Public Partial Class _Default1
Inherits System.Web.UI.MasterPage
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Public Sub updatedpage()
updatepanel1.update()
End Sub
End Class
Public Partial Class _Default5
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
LoadData()
End If
CType(Me.Master, _Default1).updatedpage()
End Sub
End Class
for finding the addtoTotal button I believe you are gonna have to do the following in the code behind
ListView listview2 = (ListView)listview1.FindControl("listview2");
LinkButton addtoTotal = (LinkButton)listview2.FindControl("addtoTotal");
you should be able to find the listview2 within the first listview and then find the LinkButton within listivew2
I'm not quite sure that I understand your question but it seems to me that this article should point you in the right direction

Resources